Xceed Encryption Library Documentation
Examples / Digitally signing a file (VB.NET example)
In This Topic
    Digitally signing a file (VB.NET example)
    In This Topic
    VB.NET Copy Code

    ' Digital signature creation example for VB.NET (single pass)            

    Dim signer As New XceedEncryptionLib.XceedSigningClass()
    signer.License( "your license key" )      

    Try
      Dim rsa As New XceedEncryptionLib.XceedRSASigningMethodClass() 

      ' The following call to SetRandomKeyPair would, in the real world,
      ' be replaced by the assignment of a Private Key to the
      ' PrivateKey property.
      Dim seed As Object = Nothing

      rsa.SetRandomKeyPair( 512, seed ) 

      ' Set the signing method type  
      signer.SigningMethod = rsa

      ' Read the file and create the digital signature
      signer.ReadFile( "c:\test\file.txt", 0, 0, XceedEncryptionLib.EXEFileProcessing.efpSign, true )

      ' Fetch the digital signature
      Dim signature As Object = rsa.Signature

      ' Verify the signature
      signer.ReadFile( "c:\test\file.txt", 0, 0, 
                       XceedEncryptionLib.EXEFileProcessing.efpVerify, true )         

    Catch except As System.Runtime.InteropServices.COMException
      MessageBox.Show( except.ToString() )
    End Try