Function to convert text to MD5 code. Error on some windows 10 computers

Excelpromax123

Board Regular
Joined
Sep 2, 2021
Messages
167
Office Version
  1. 2010
Platform
  1. Windows
Hello everyone. I have used a function to convert a text to MD5 code. But win 10 has a number of machines that give empty results (Win 7 does not see it). Thanks for everyone's help with the code to fix it. Thank you

Code:
VBA Code:
Public Function md5convet(textString As String) As String
On Error Resume Next
Dim enc
Dim textBytes() As Byte
Dim bytes
Dim outstr As String
Set enc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
textBytes = textString
bytes = enc.ComputeHash_2((textBytes))
For pos = 1 To LenB(bytes)
outstr = outstr & LCase(Right("0" & Hex(AscB(MidB(bytes, pos, 1))), 2))
Next
md5convet = outstr
Set enc = Nothing
End Function

Sub Test()
MsgBox (md5convet("abc"))
End Sub
1639732901687.png
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
I'd imagine those machines are missing the relevant .Net library. A pretty good example of why just putting On Error Resume Next at the top of a routine doesn't really do you any favours... ;)
 
Upvote 0
Not all machines will have .Net installed on them. I ran into this problem, you're much safer including the code to generate the hash in VBA

Rory beat me to it!
 
Upvote 0
I'd imagine those machines are missing the relevant .Net library. A pretty good example of why just putting On Error Resume Next at the top of a routine doesn't really do you any favours... ;)
It shows this error
1639734594446.png
 
Upvote 0

Forum statistics

Threads
1,214,849
Messages
6,121,922
Members
449,056
Latest member
denissimo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top