Hi,
May be some one specifically knows about this problem and solution.
I am using SHA256 hash function for password and some other things (app security). This function has been working fine, without any problems for the last 3 years, with mutli-User app (more than 35 user accounts). Hashed passwords are stored at registration and hashed are checked at login. (as I said not only limited to passwords).
At this stage changing the function is not possible because all users have to change passwords then.
Problem:
Today I had to do new windows installation, on my PC along with fresh copy of MS office 2021 (the same which I have been using before). After I did this update,
now I am getting this while I open the app (only at the pages where I have called this function).
1) I have other two PCs, where app works fine.
2) Problematic PC: has same window 11 as before, same ms office as before. fresh installed.
I also installed latest version of .NET Framework 4.8 Developer Pack
3) I tried to figure out line in the function (as in code),
then I got this
Error -2146232576 in SHA256: Automation error at line 0 , again indicating function itself has no problem.
4) I tried running this (regsvr32 msxml3.dll) and "DllRegisterServer in msxml3.dll succeeded".
I also checked
I checked this on the PC where my program works, then I compared with the PC where i have problem..
on both PC available references are tick marked.
1) Visual basic for applications
2) Micro... Access 16.0 Object Library
3) OLE Automation
4) Micro.... office 16.0 Access database engine object Library
I have no other libraries activated.
Few weeks back, this error happened (Error -21462325756 in SHA256: Automation error in Ms access) on one of the PC of a client for another app, because app was at its initial stage so I had to replace the function completely.
Did any one encountered such problem (because it is not general, rather it is PC specific. Few PCs give this error while mostly not.)
As I said, I got this problem after more three years, and it has been being used more than 50 different PCs at least. Function itself has no problem at all. Probably any component is missing in such PCs.
Many thanks.
------------------------------------------------------------------
May be some one specifically knows about this problem and solution.
I am using SHA256 hash function for password and some other things (app security). This function has been working fine, without any problems for the last 3 years, with mutli-User app (more than 35 user accounts). Hashed passwords are stored at registration and hashed are checked at login. (as I said not only limited to passwords).
At this stage changing the function is not possible because all users have to change passwords then.
Problem:
Today I had to do new windows installation, on my PC along with fresh copy of MS office 2021 (the same which I have been using before). After I did this update,
now I am getting this while I open the app (only at the pages where I have called this function).
1) I have other two PCs, where app works fine.
2) Problematic PC: has same window 11 as before, same ms office as before. fresh installed.
I also installed latest version of .NET Framework 4.8 Developer Pack
3) I tried to figure out line in the function (as in code),
then I got this
Error -2146232576 in SHA256: Automation error at line 0 , again indicating function itself has no problem.
4) I tried running this (regsvr32 msxml3.dll) and "DllRegisterServer in msxml3.dll succeeded".
I also checked
I checked this on the PC where my program works, then I compared with the PC where i have problem..
on both PC available references are tick marked.
1) Visual basic for applications
2) Micro... Access 16.0 Object Library
3) OLE Automation
4) Micro.... office 16.0 Access database engine object Library
I have no other libraries activated.
Few weeks back, this error happened (Error -21462325756 in SHA256: Automation error in Ms access) on one of the PC of a client for another app, because app was at its initial stage so I had to replace the function completely.
Did any one encountered such problem (because it is not general, rather it is PC specific. Few PCs give this error while mostly not.)
As I said, I got this problem after more three years, and it has been being used more than 50 different PCs at least. Function itself has no problem at all. Probably any component is missing in such PCs.
Many thanks.
------------------------------------------------------------------
Code:
Option Compare Database
Option Explicit
' This function uses SHA256 to hash the input string
Public Function MYFUNCTIONNAME(ByVal sInput As String) As String
On Error GoTo ErrorHandler
MYFUNCTIONNAME = SHA256(sInput)
Exit Function
ErrorHandler:
MsgBox "Error in MYFUNCTIONNAME: " & Err.Description
MYFUNCTIONNAME = ""
End Function
Public Function SHA256(ByVal sInput As String, Optional ByVal bB64 As Boolean = False) As String
On Error GoTo ErrorHandler
' Create objects for encoding and hashing
Dim Encoder As Object
Set Encoder = CreateObject("System.Text.UTF8Encoding")
Dim Hasher As Object
Set Hasher = CreateObject("System.Security.Cryptography.SHA256Managed")
Dim TextToHash() As Byte
TextToHash = Encoder.GetBytes_4(sInput)
Dim Hash() As Byte
Hash = Hasher.ComputeHash_2(TextToHash)
' Convert the hash to the desired format
If bB64 = True Then
SHA256 = ConvToBase64String(Hash)
Else
SHA256 = ConvToHexString(Hash)
End If
Exit Function
ErrorHandler:
MsgBox "Error " & Err.Number & " in SHA256: " & Err.Description
SHA256 = ""
End Function
Public Function ConvToBase64String(ByVal vIn As Variant) As Variant
On Error GoTo ErrorHandler
Dim oD As Object
Set oD = CreateObject("MSXML2.DOMDocument")
With oD
.LoadXML "<root />"
.DocumentElement.DataType = "bin.base64"
.DocumentElement.nodeTypedValue = vIn
End With
ConvToBase64String = Replace(oD.DocumentElement.Text, vbLf, "")
Exit Function
ErrorHandler:
MsgBox "Error in ConvToBase64String: " & Err.Description
ConvToBase64String = ""
End Function
Public Function ConvToHexString(ByVal vIn As Variant) As Variant
On Error GoTo ErrorHandler
' Create a DOMDocument object
Dim oD As Object
Set oD = CreateObject("MSXML2.DOMDocument")
' Load the byte array as hexadecimal data
With oD
.LoadXML "<root />"
.DocumentElement.DataType = "bin.Hex"
.DocumentElement.nodeTypedValue = vIn
End With
ConvToHexString = Replace(oD.DocumentElement.Text, vbLf, "")
Exit Function
ErrorHandler:
MsgBox "Error in ConvToHexString: " & Err.Description
ConvToHexString = ""
End Function
Last edited: