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