我有一个Web服务加载驱动程序,它是一个Windows脚本文件(WSF),包括一些VBScript和JavaScript文件.我的Web服务要求传入的消息是base64编码的.我目前有一个VBScript函数可以做到这一点,但效率很低(内存密集,主要是由于VBScripts可怕的字符串连接)
[在旁边; 是的,我见过杰夫的最新博文.串联发生在跨越1,000到10,000字节大小的消息的循环中.
我尝试过使用一些自定义字符串连接例程; 一个使用数组,一个使用ADODB.Stream.这些帮助,一点点,但我认为如果我有其他方式编码消息而不是通过我自己的VBS功能,它会有所帮助.
有没有其他方式编码我的消息,优先使用本机Windows方法?
我正在尝试在VBA(Excel 2003)上计算字符串的哈希,但是当我调用时ComputeHash,它将抛出Invalid argument/procedure call错误。
DLL参考:mscorlib v4.0,System v4.0
MSDN参考:http : //msdn.microsoft.com/zh-cn/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
Run Code Online (Sandbox Code Playgroud)