Xojo 2021 Release 3 has a few improvements to the Crypto module that you might find useful.
A new SHA3 algorithm is available for use with the Hash function. You can now use SHA3-256 (SHA3 with 256-bit digest) and SHA3-512 (SHA3 with a 512 bit digest) from the Crypto.HashAlgorithms enumeration for stronger encryption or compatibility with something else that uses them.
Var hash As String hash = Crypto.Hash("YourPasswordSentence", Crypto.HashAlgorithms.SHA3_512)
BlowFish / TwoFish
The BlowFish and TwoFish encryption algorithms can now be used in Xojo. These two algorithms are similar, with BlowFish being the original algorithm and TwoFish being a newer, more secure version that was derived from BlowFish.
You can use either to encrypt data, but in general you’ll want to avoid BlowFish for your own code, although it might prove useful for compatibility with other libraries or tools.
Var encrypted As MemoryBlock Var dataToEncrypt As MemoryBlock = "Secret!" Var key As MemoryBlock = Crypto.GenerateRandomBytes(16) Var initVector As MemoryBlock = Crypto.GenerateRandomBytes(16) encrypted = Crypto.AESEncrypt(key, dataToEncrypt, Crypto.BlockModes.CBC, initVector) Var decrypted As MemoryBlock decrypted = Crypto.AESDecrypt(key, encrypted, Crypto.BlockModes.CBC, initVector) // decrypted = "Secret!"
CRC32 is just a simple way to test data integrity and is not cryptographically secure. It still has its uses for fast data comparison and simple hash tables. It can be called like this:
Var crc32 As String crc32 = Crypto.Hash("StringOrDataToTest", Crypto.HashAlgorithms.CRC32)
RSASign now takes an optional parameter and RSASignModes let you specify the hash to use.
Learn more about the Crypto module in the Xojo Documentation.
Updated (Nov 22, 2021): Added AES section