If you work with different types of encrypted data it is often quite useful to have a utility available from which you can utilize to encrypt a String to a specific encryption format.
I find it particularly useful to isolate each available encryption object into a single Helper / Utility class to help facilitate encryption requests; essentially providing a wrapper for all encryption objects.
The Encryption utility is an all static class which is intended to provide a solution for centralizing access to encryption classes. The Encryption utility simply wraps all encryption types available in a Flex Application and provides a single static method for encrypting a String to the specified encryption type.
Additionally, the Encryption utility provides constants which represent each supported encryption type; SHA-256, SHA1 and MD5.
Using the Encryption utility is simple and straightforward as one might expect. The following examples demonstrate a typical use-case in which a String; “test”, is encrypted utilizing each defined encryption type:
1 2 3 4 5 6 7 8 9 10 11 | trace(Encryption.encrypt("test",Encryption.CRYPTO_SHA256)); //df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b8 //1119 trace(Encryption.encrypt("test",Encryption.CRYPTO_SHA1)); //a94a8fe5ccb19ba61c4c0873d391e987982fbbd3 trace(Encryption.encrypt("test",Encryption.CRYPTO_MD5)); //098f6bcd4621d373cade4e832627b4f6 |
So if you need an easy to use, centralized location from which you can conveniently call up to encrypt a String, feel free to utilize the Encryption utility.
The Encryption utility is protected under the MIT license.
{Sorry, Comments are currently Closed! }