Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
SHA-1 Hash
Visual Basic sample code to create a SHA-1 hash of a file. Private Sub Command1_Click()
Dim nfile As Long
Dim filelength As Long ' length of document
Dim filedata As Variant ' file data read from document
Dim crypt As New ChilkatCrypt2
crypt.UnlockComponent "Anything for 30-day trial"
' Set the hash algorithm
crypt.HashAlgorithm = "sha-1"
' Read the file as binary data.
nfile = FreeFile
Open "hashThis.txt" For Binary As nfile
filelength = LOF(nfile)
filedata = InputB(filelength, nfile)
' Provide output as a hex-encoded string.
crypt.EncodingMode = "hex"
Text1.Text = crypt.HashBytesENC(filedata)
' Do it again, but return the result as a base-64 encoded string.
crypt.EncodingMode = "base64"
Text2.Text = crypt.HashBytesENC(filedata)
End Sub
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.