Creating a Signature

See also Generating a Public/Private Key Pair and Listing All Available Signature Algorithms.
// Returns the signature for the given buffer of bytes using the private key. public static byte[] createSignature(PrivateKey key, byte[] buffer) { try { Signature sig = Signature.getInstance(key.getAlgorithm()); sig.initSign(key); sig.update(buffer, 0, buffer.length); return sig.sign(); } catch (SignatureException e) { } catch (InvalidKeyException e) { } catch (NoSuchAlgorithmException e) { } return null; }

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.