{"id":166,"date":"2007-10-06T06:54:12","date_gmt":"2007-10-06T14:54:12","guid":{"rendered":"http:\/\/www.ericfeminella.com\/blog\/2007\/10\/06\/md5-sha1-and-sha-256-encryption-utility\/"},"modified":"2012-03-04T23:31:14","modified_gmt":"2012-03-05T04:31:14","slug":"md5-sha1-and-sha-256-encryption-utility","status":"publish","type":"post","link":"https:\/\/www.ericfeminella.com\/blog\/2007\/10\/06\/md5-sha1-and-sha-256-encryption-utility\/","title":{"rendered":"MD5, SHA1 and SHA-256 Encryption Utility"},"content":{"rendered":"<p>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.<\/p>\n<p>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.<\/p>\n<p>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. <\/p>\n<p>Additionally, the Encryption utility provides constants which represent each supported encryption type; <a href=\"http:\/\/csrc.nist.gov\/publications\/fips\/fips180-2\/fips180-2.pdf\" target=\"_blank\">SHA-256<\/a>, <a href=\"http:\/\/www.faqs.org\/rfcs\/rfc3174.html\" target=\"_blank\">SHA1<\/a> and <a href=\"http:\/\/www.faqs.org\/rfcs\/rfc1321.html\" target=\"_blank\">MD5<\/a>.<\/p>\n<p>Using the Encryption utility is simple and straightforward as one might expect. The following examples demonstrate a typical use-case in which a String; &#8220;test&#8221;, is encrypted utilizing each defined encryption type:<\/p>\n<pre lang=\"actionscript\">\r\n\r\ntrace(Encryption.encrypt(\"test\",Encryption.CRYPTO_SHA256));\r\n\/\/df3f619804a92fdb4057192dc43dd748ea778adc52bc498ce80524c014b8\r\n\/\/1119\r\n\r\ntrace(Encryption.encrypt(\"test\",Encryption.CRYPTO_SHA1));\r\n\/\/a94a8fe5ccb19ba61c4c0873d391e987982fbbd3\r\n\r\ntrace(Encryption.encrypt(\"test\",Encryption.CRYPTO_MD5));\r\n\/\/098f6bcd4621d373cade4e832627b4f6<\/pre>\n<p>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 <a href=\"http:\/\/code.ericfeminella.com\/classes\/as3\/Encryption.as.html\" target=\"_blank\">Encryption<\/a> utility.<\/p>\n<p>The Encryption utility is protected under the <a href=\"http:\/\/www.opensource.org\/licenses\/mit-license.php\" target=\"_blank\">MIT license<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230; <a class=\"read-more\" href=\"https:\/\/www.ericfeminella.com\/blog\/2007\/10\/06\/md5-sha1-and-sha-256-encryption-utility\/\">Continue Reading<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[35],"tags":[],"class_list":["post-166","post","type-post","status-publish","format-standard","hentry","category-software-engineering"],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/166","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/comments?post=166"}],"version-history":[{"count":0,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/posts\/166\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/media?parent=166"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/categories?post=166"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ericfeminella.com\/blog\/wp-json\/wp\/v2\/tags?post=166"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}