CryptoSys PKI Pro Manual

Example: Cms.MakeSigData  Rsa.KeyBits  Rsa.ReadPrivateKey 

[VB6 equivalent: CMS_MakeSigData]

Dim strPriFile As String
Dim sbPrivateKey As StringBuilder
Dim nRet As Integer
Dim strInputFile As String
Dim strOutputFile As String
Dim strCertFile As String

strPriFile = "AlicePrivRSASign.pri"
strCertFile = "AliceRSASignByCarl.cer"
strInputFile = "excontent.txt"
strOutputFile = "BasicSignByAlice.bin"

' First we need to read in the private key string
' NB: This version is not encrypted, so no password needed
sbPrivateKey = Rsa.ReadPrivateKey(strPriFile, "")
Console.WriteLine("nIntKeyLen = " & sbPrivateKey.Length)
If sbPrivateKey.Length = 0 Then
    Console.WriteLine(General.LastError())
    Console.WriteLine("Unable to retrieve private key")
    Exit Sub
End If
Console.WriteLine("Key size=" & Rsa.KeyBits(sbPrivateKey.ToString()) & " bits")

' Now we can sign our message
nRet = Cms.MakeSigData(strOutputFile, strInputFile, strCertFile, sbPrivateKey.ToString, HashAlgorithm.Sha1, 0)
Console.WriteLine("CMS_MakeSigData returns " & nRet)

See Also:
Cms.MakeSigData Method ( String, String, String, String, Cms.SigAlg, Cms.SigDataOptions)
Cms.MakeSigData Method ( String, String, String, String, HashAlgorithm, Cms.SigDataOptions)

[Contents] [Index]

[PREV: Example: Cms.MakeEnvDataFromString ...]   [Contents]   [Index]   
   [NEXT: Example: Cms.MakeSigData ...]

Copyright © 2004-23 D.I. Management Services Pty Ltd. All rights reserved. Generated 2023-09-18T10:02:53Z.