use of com.bluenimble.platform.crypto.signer.StringKey in project serverless by bluenimble.
the class SignVerifyDocumentWithKey method main.
public static void main(String[] args) throws StoreLoaderException, UnrecoverableKeyException, KeyStoreException, NoSuchAlgorithmException, CertificateException, SignerException, IOException {
Signer signer = new SimpleSigner();
Key key = new StringKey("mykey", Algorithm.HmacSHA1);
StringSignatureAwareSecureDocument doc = new StringSignatureAwareSecureDocument("a document to sign");
doc.setKey(key);
signer.sign(doc, key, null);
System.out.println(new String(doc.getSignature(), DefaultSigner.BASE64_ENCODING));
signer.verify(doc, null);
System.out.println(new String(doc.getBytes()));
}
Aggregations