Platforms to show: All Mac Windows Linux Cross-Platform

Back to SHA1MBS class.

SHA1MBS.Hash(data as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Encryption Plugin 3.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the hash string for the given key.
Example
MsgBox EncodeHex(SHA1MBS.Hash("Hello World"))

The string returned is 20 bytes long (if successfull) and has the 5 integer properties stored inside (in big endian format) which make up the key.
Does change the current hash value stored in the class itself.

SHA1MBS.HashFile(file as FolderItem, Hex as boolean = true) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Encryption Plugin 14.2 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Calculates hash from whole file.

Plugin will start a preemptive thread to read in file and process all data in chunks.
Returns hash on success or empty string on failure. May raise OutOfMemoryException or IOException.
This function works best if called from a thread.
If hex is true, the result is encoded as hex string.

The work is performed on a preemptive thread, so this function does not block the application and can yield time to other Xojo threads. Must be called in a Xojo thread to enjoy benefits. If called in main thread will block, but keep other background threads running.
If you run several threads calling MT methods, you can get all CPU cores busy while main thread shows GUI with progress window.

SHA1MBS.HashText(data as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Encryption Plugin 13.5 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the hash string for the given key.
Example
MsgBox EncodeHex(SHA1MBS.Hash("Hello World"))

The string returned is 20 bytes long (if successfull) and has the 5 integer properties stored inside (in big endian format) which make up the key.
Does change the current hash value stored in the class itself.
Returns the digest as text string with hexadecimal digits.

SHA1MBS.HMAC(key as string, data as string) as string

Type Topic Plugin Version macOS Windows Linux iOS Targets
shared method Encryption and Hash MBS Encryption Plugin 3.1 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
Returns the a specific HASH based on the key and the data string.
Example
Function HMAC(key as string, data as string) As string
// Implementation by Matthijs van Duin
#pragma DisableBackgroundTasks

dim ikey, okey, k as string
dim temp, i as Integer

if (lenB(key) > 64) then
k = Hash(key)
else
k = key
end if

for i = 1 to 64
temp = ascB(midB(k, i, 1))
ikey = ikey + chrB(BitwiseXor(temp, &h36))
okey = okey + chrB(BitwiseXor(temp, &h5C))
next

return Hash(okey + Hash(ikey + data))
End Function

// test code:

// de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9
dim s as string = SHA1MBS.HMAC("key", "The quick brown fox jumps over the lazy dog")
MsgBox EncodeHex(s)

// fbdb1d1b18aa6c08324b7d64b71fb76370690e1d
s = SHA1MBS.HMAC("", "")
MsgBox EncodeHex(s)

Above is the source code of this function.

The items on this page are in the following plugins: MBS Encryption Plugin.


The biggest plugin in space...