-
-
Notifications
You must be signed in to change notification settings - Fork 3
Generic Hash Example
Andrew Lambert edited this page Nov 26, 2022
·
6 revisions
libsodium provides general purpose hashing using keyed or unkeyed BLAKE2b/SHA256/SHA512. These hash algorithms are not suitable for password hashing.
This example hashes a file using un-keyed BLAKE2b:
Dim f As FolderItem = GetOpenFolderItem("")
Dim bs As BinaryStream = BinaryStream.Open(f)
Dim h As New libsodium.GenericHashDigest()
Do Until bs.EOF
h.Process(bs.Read(4096))
Loop
MsgBox(libsodium.EncodeHex(h.Value))
This example hashes a file using SHA512:
Dim f As FolderItem = GetOpenFolderItem("")
Dim bs As BinaryStream = BinaryStream.Open(f)
Dim h As New libsodium.GenericHashDigest(libsodium.HashType.SHA512)
Do Until bs.EOF
h.Process(bs.Read(4096))
Loop
MsgBox(libsodium.EncodeHex(h.Value))
This example hashes a file using SHA256:
Dim f As FolderItem = GetOpenFolderItem("")
Dim bs As BinaryStream = BinaryStream.Open(f)
Dim h As New libsodium.GenericHashDigest(libsodium.HashType.SHA256)
Do Until bs.EOF
h.Process(bs.Read(4096))
Loop
MsgBox(libsodium.EncodeHex(h.Value))
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2016-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.