Introducing WinCrypt for VA Smalltalk
WinCrypt is a new library for VA Smalltalk on Windows. It makes part of the cryptography functionality that is shipped with the Windows OS easily available from Smalltalk.
The following features are available in the initial version:
- Symmetric encryption and decryption using RC4, DES, TripleDES and AES-256
- The MD5, SHA and SHA-256 hash functions
- The HMAC-MD5, HMAC-SHA and HMAC-SHA-256 message authentication functions.
The API is pretty simple to use. To encrypt a String or ByteArray using a password you can use the class methods defined in WinCryptCipher:
| encryptedBytes | encryptedBytes := WinCryptAES encrypt: 'my-dirty-little-secret' using: 'puppy'
The results is always a ByteArray. This ByteArray can be decrypted and converted to a String:
| encryptedBytes decryptedBytes | encryptedBytes := WinCryptAES encrypt: 'my-dirty-little-secret' using: 'puppy'. decryptedBytes := WinCryptAES decrypt: encryptedBytes using: 'puppy'. ^decryptedBytes asString
The ciphers use a key with a specific size for encryption and decryption. When you provide a password string the key is derived from this password using the MD5 hash algorithm. It is also possible to skip this step and supply your own key.
The WinCrypt library is open source and is published on VAStGoodies.com. The included SUnit tests show how the library can be used. The underlying Windows functions are documented on MSDN.
Tags: vasmalltalk
You can comment below, or link to this permanent URL from your own site.