Sign documents with encrypted metadata text
Leave feedback
GroupDocs.Signature provides ability to secure Metadata signatures with standard or custom encryption. Standard encryption is implemented over class SymmetricEncryption class. Creation of this object expects 3 arguments like encryption algorithm enumeration SymmetricAlgorithmType with one of following values (DES, TripleDES, RC2, Rijndael), string value key and string value salt.
Here are the steps to secure Metadata string values with standard encryption with GroupDocs.Signature:
Create new instance of Signature class and pass source document path or stream as a constructor parameter.
Compose object of SymmetricEncryption class with required algorithm and secure pair key/salt
Alternative way to encrypt only selected Metadata signatures is to setup property MetadataSignature.setDataEncryption to each signature that requires to be secured.
This example shows how to sign document with encrypted Metadata signatures over .
Signaturesignature=newSignature("sample.docx");// setup key and passphrase
Stringkey="1234567890";Stringsalt="1234567890";// create data encryption
IDataEncryptionencryption=newSymmetricEncryption(SymmetricAlgorithmType.Rijndael,key,salt);// setup options with text of signature
MetadataSignOptionsoptions=newMetadataSignOptions();// setup signature metadata
WordProcessingMetadataSignaturemdAuthor=newWordProcessingMetadataSignature("Author","Mr.Scherlock Holmes");// setup data of document id
WordProcessingMetadataSignaturemdDocId=newWordProcessingMetadataSignature("DocumentId",java.util.UUID.randomUUID().toString());// add signatures to options
options.getSignatures().add(mdAuthor);options.getSignatures().add(mdDocId);// sign document to file
SignResultsignResult=signature.sign("MetadataEncryptedText.docx",options);// analyzing result
System.out.print("List of newly created signatures:");intnumber=1;for(BaseSignaturetemp:signResult.getSucceeded()){System.out.print("Signature #"+number+++": Type: "+temp.getSignatureType()+" Id:"+temp.getSignatureId()+",Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());}
Implementation of encrypted Metadata signature over MetadataSignOptions encryption
This example shows how to sign document with encrypted Metadata signatures over .
Signaturesignature=newSignature("sample.docx");// setup key and passphrase
Stringkey="1234567890";Stringsalt="1234567890";// create data encryption
IDataEncryptionencryption=newSymmetricEncryption(SymmetricAlgorithmType.Rijndael,key,salt);// setup options with text of signature
MetadataSignOptionsoptions=newMetadataSignOptions();// set encryption for all metadata signatures for this options
// if you need separate encryption use own MetadataSignature.DataEncryption property
options.setDataEncryption(encryption);// setup signature metadata
WordProcessingMetadataSignaturemdAuthor=newWordProcessingMetadataSignature("Author","Mr.Scherlock Holmes");// setup data of document id
WordProcessingMetadataSignaturemdDocId=newWordProcessingMetadataSignature("DocumentId",java.util.UUID.randomUUID().toString());// add signatures to options
options.getSignatures().add(mdAuthor);options.getSignatures().add(mdDocId);// sign document to file
SignResultsignResult=signature.sign("MetadataEncryptedText.docx",options);// analyzing result
System.out.print("List of newly created signatures:");intnumber=1;for(BaseSignaturetemp:signResult.getSucceeded()){System.out.print("Signature #"+number+++": Type: "+temp.getSignatureType()+" Id:"+temp.getSignatureId()+",Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full-featured .NET library we provide simple, but powerful free Apps. You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.