【发布时间】:2015-01-22 17:33:02
【问题描述】:
我正在尝试在 VBA (Excel 2003) 上计算字符串的哈希值,但是当我调用 ComputeHash 时,它会抛出 Invalid argument/procedure call 错误。
DLL 参考:mscorlib v4.0、System v4.0
MSDN 参考:http://msdn.microsoft.com/en-us/library/system.security.cryptography.sha512managed.aspx
Sub Main()
Dim instance As New SHA512Managed
Dim data() As Byte
data = StringToByte("mymsg")
Dim result() As Byte
instance.ComputeHash(data) 'Throws runtime error'
MsgBox (ByteToString(result))
End Sub
Function StringToByte(ByVal s)
Dim b() As Byte
b = s 'Assign Unicode string to bytes.'
StringToByte = b
End Function
Function ByteToString(ByVal dBytes)
Dim strText As String
strText = dBytes
ByteToString = strText
End Function
【问题讨论】:
-
该引用 (SHA512Managed) 来自(哪个库)?我有几个不同版本的 mscorlib.dll,但无法将它们链接到 VBE...
-
mscorlib.dll v4.0,带有系统 v4.0
-
你是说.NET?我的 .dll 仅适用于 .NET 2.0,但我仍然无法添加引用。无论如何,我正在添加一个我无法测试的答案......