I have an office laptop which doesn't allow installation of 3.5 .netframework hence cant use below function for hashing in VBA
System.Security.Cryptography.SHA256Managed
Was wondering is there an alternative code or procedure to use 256 hashing with standard 4.8 .net framework containers ?
Thanks
Tried using below code but not yielding result
Function StringToSHA256Hex(ByVal s As String) As String
Dim enc As Object
Dim bytes() As Byte
Dim pos As Long
Dim outstr As String
Set enc = CreateObject("System.Security.Cryptography.SHA256Managed")
bytes = StrConv(s, vbFromUnicode)
bytes = enc.ComputeHash_2(bytes)
For pos = LBound(bytes) To UBound(bytes)
outstr = outstr & LCase(Right("0" & Hex(bytes(pos)), 2))
Next pos
StringToSHA256Hex = outstr
Set enc = Nothing
End Function
The reason is that the library is obsolete. Also, you should be able to use VBA and the CNG (Next Generation Cryptography) API only.
For example:
taken from my repository at GitHub: VBA.Cryptography.