I'm getting a type mismatch error when I try to run an SQL statement like this:
Dim s
s = "test"
"SELECT id FROM mytable WHERE sha1bin = " & SHA1bin(s)
Here's my SHA1bin function:
Private Function SHA1Bin(s)
Dim asc, enc, bytes
Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.SHA1CryptoServiceProvider")
bytes = asc.GetBytes_4(s)
SHA1Bin = enc.ComputeHash_2((bytes))
Set asc = Nothing
Set enc = Nothing
End Function
As I understand it VBScript doesn't really have a binary data type. What do I need to do to make this comparison or should I store it as a 40 Character Hex value instead so I can do a text comparison?
"SELECT id FROM mytable WHERE sha1bin = '" & SHA1bin(s) & "'"?