Creates a SHA-1 message digest in hexadecimal format from a file.
VB6/VBA
Debug.Print "Testing SHA1_FileHexHash ..." Dim nRet As Long Dim strDigest As String Dim strFileName As String strFileName = "hello.txt" ' Set strDigest to be 40 chars strDigest = String(40, " ") ' Make sha1sum in text mode (treating CR-LF as single NL) nRet = SHA1_FileHexHash(strDigest, strFileName, "t") Debug.Print "t ", nRet, strDigest ' Do in binary mode (treating CR-LF as two binary bytes) nRet = SHA1_FileHexHash(strDigest, strFileName, "b") Debug.Print "b ", nRet, strDigest
Output
Testing SHA1_FileHexHash ... t 0 22596363b3de40b06f981fb85d82312e8c0ed511 b 0 88a5b867c3d110207786e66523cd1e4a484da697
VB.NET
Console.WriteLine("Testing SHA1_FileHexHash ...") ''Dim nRet As Integer Dim strDigest As String Dim strFileName As String strFileName = "hello.txt" ' Set strDigest to be 40 chars ''strDigest = String(40, " ") ' Make sha1sum in text mode (treating CR-LF as single NL) strDigest = Sha1.FileTextHexHash(strFileName) Console.WriteLine("t " & " " & strDigest) ' Do in binary mode (treating CR-LF as two binary bytes) strDigest = Sha1.FileHexHash(strFileName) Console.WriteLine("b " & " " & strDigest)
[Contents]