我正在尝试从我提供的私钥和散列值创建签名。我正在使用 DSA 和以下代码,但收到以下错误:
指定的类型无效。源 mscorlib
此行引发错误:ImportCspBlob(pk)
Private Function key() As String
Dim privatekey As String = "-----BEGIN DSA PRIVATE KEY-----" _
& "Key Data"
& "-----END DSA PRIVATE KEY-----"
Dim dsa As DSACryptoServiceProvider = New DSACryptoServiceProvider()
Dim pk As Byte() = Encoding.ASCII.GetBytes(privatekey)
dsa.ImportCspBlob(pk)
Dim st As Byte() = Encoding.ASCII.GetBytes("THIS IS THE HASH STRING")))
Dim signedValue As Byte() = dsa.SignHash(st, "SHA1")
Return Encoding.ASCII.GetString(signedValue)
End Function
谁能告诉我我是在正确的路线上还是我出路了?
对此的任何帮助将不胜感激。