SHA/MD5 Checksums

iliauk

Board Regular
Joined
Jun 3, 2014
Messages
163
Hi everyone; I would like to incorporate into my script that recursively lists all files in a folder/directory the ability to also generate an SHA1 checksum (or any really) for that file. I would appreciate any leads someone could offer on the matter.

I have a function I was using for other purposes that does SHA - maybe that can be modified?

Code:
Function Base64_HMACSHA1(ByVal sTextToHash As String, ByVal sSharedSecretKey As String)
Dim asc As Object, enc As Object
Dim TextToHash() As Byte
Dim SharedSecretKey() As Byte
Dim bytes() As Byte


Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.HMACSHA1")


'Only need to hash path
sTextToHash = Replace(sTextToHash, "https://maps.googleapis.com", "")
TextToHash = asc.Getbytes_4(sTextToHash)
'Decode sSharedSecretKey
SharedSecretKey = DecodeBase64(sSharedSecretKey)
'SharedSecretKey = asc.Getbytes_4(sSharedSecretKey)
enc.key = SharedSecretKey


bytes = enc.ComputeHash_2((TextToHash))
Base64_HMACSHA1 = EncodeBase64(bytes)

However, here I am hashing a URL whereas with the file I guess I can't just use the file-name but need to get further access.

Thanks!
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,335
Messages
6,124,326
Members
449,155
Latest member
ravioli44

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