Xceed Encryption Library Documentation
Examples / Signing and verifying data entirely in memory (VB example)
In This Topic
    Signing and verifying data entirely in memory (VB example)
    In This Topic
    Visual Basic Copy Code

    Dim xSign As New XceedSigning
    Dim vaSource As Variant
    Dim vaSignature As Variant 

    Set xSign.SigningMethod = New XceedRSASigningMethod 

    vaSource = "This is the data to sign" 

    On Error Resume Next 

      ' The following call to SetRandomKeyPair would, in the real world,
      ' be replaced by the assignment of a Private Key to the
      ' PrivateKey property. 

      Call xSign.SigningMethod.SetRandomKeyPair( 512, Empty )
      Call xSign.Sign(vaSource, True)

      vaSignature = xSign.SigningMethod.Signature 

      ' Do something with the signature 

      If Err.Number <> 0 Then
        Call MsgBox("Error 0x" & Hex(Err.Number) & " " & Err.Description) 
      Else
        Call MsgBox("Data signed successfully") 
      End If 

      If xSign.Verify(vaSource, True) Then
        Call MsgBox("Data verified successfully") 
      Else
        ' Should not happen 
        Call MsgBox("Verification of signature failed") 
      End If 

    On Error Goto 0

    Set xSign = Nothing