{"id":1075,"date":"2013-11-11T11:11:01","date_gmt":"2013-11-11T14:11:01","guid":{"rendered":"http:\/\/www.franklinjr.com\/blog\/?p=1075"},"modified":"2013-11-11T11:11:01","modified_gmt":"2013-11-11T14:11:01","slug":"exemplo-encryptdecrypt-em-coldfusion","status":"publish","type":"post","link":"https:\/\/www.franklinjr.com\/blog\/index.php\/2013\/11\/11\/exemplo-encryptdecrypt-em-coldfusion\/","title":{"rendered":"Exemplo encrypt\/decrypt em ColdFusion"},"content":{"rendered":"<p>Cole o c\u00f3digo em um arquivo .cfm para testar.<\/p>\n<pre lang=\"cfm\" line=\"1\"> \r\n<h3>Encrypt Example<\/h3> \r\n<!--- Do the following if the form has been submitted. ---> \r\n<cfif IsDefined(\"Form.myString\")> \r\n    <cfscript> \r\n        \/* GenerateSecretKey does not generate key for the CFMX_COMPAT algorithm, \r\n        so use the key from the form. \r\n        *\/ \r\n        if (Form.myAlgorithm EQ \"CFMX_COMPAT\") \r\n            theKey=Form.MyKey; \r\n        \/\/ For all other encryption techniques, generate a secret key. \r\n        else \r\n            theKey=generateSecretKey(Form.myAlgorithm); \r\n        \/\/Encrypt the string \r\n        encrypted=encrypt(Form.myString, theKey, Form.myAlgorithm, \r\n            Form.myEncoding); \r\n        \/\/Decrypt it \r\n        decrypted=decrypt(encrypted, theKey, Form.myAlgorithm, Form.myEncoding); \r\n    <\/cfscript> \r\n \r\n    <!--- Display the values used for encryption and decryption,  \r\n            and the results. ---> \r\n    <cfoutput> \r\n        <b>The algorithm:<\/b> #Form.myAlgorithm#<br> \r\n        <b>The key:<\/B> #theKey#<br> \r\n        <br> \r\n        <b>The string:<\/b> #Form.myString# <br> \r\n        <br> \r\n        <b>Encrypted:<\/b> #encrypted#<br> \r\n        <br> \r\n        <b>Decrypted:<\/b> #decrypted#<br> \r\n    <\/cfoutput> \r\n<\/cfif> \r\n \r\n<!--- The input form.---> \r\n<form action=\"#CGI.SCRIPT_NAME#\" method=\"post\"> \r\n    <b>Select the encoding<\/b><br> \r\n    <select size=\"1\" name=\"myEncoding\"> \r\n        <option selected>UU<\/option> \r\n        <option>Base64<\/option> \r\n        <option>Hex<\/option> \r\n    <\/select><br> \r\n    <br> \r\n    <b>Select the algorithm<\/b><br> \r\n    <select size=\"1\" name=\"myAlgorithm\"> \r\n        <option selected>CFMX_COMPAT<\/option> \r\n        <option>AES<\/option> \r\n        <option>DES<\/option> \r\n        <option>DESEDE<\/option> \r\n    <\/select><br> \r\n    <br> \r\n    <b>Input your key<\/b> (used for CFMX_COMPAT encryption only)<br> \r\n    <input type = \"Text\" name = \"myKey\" value = \"MyKey\"><br> \r\n    <br> \r\n    <b>Enter string to encrypt<\/b><br> \r\n    <textArea name = \"myString\" cols = \"40\" rows = \"5\" WRAP = \"VIRTUAL\">This string will be encrypted (you can replace it with more typing). \r\n    <\/textArea><br> \r\n    <input type = \"Submit\" value = \"Encrypt my String\"> \r\n<\/form>\r\n<\/pre>\n<p>Retirado <a href=\"http:\/\/help.adobe.com\/en_US\/ColdFusion\/9.0\/CFMLRef\/WSc3ff6d0ea77859461172e0811cbec22c24-7c2f.html\" target=\"_blank\">daqui<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Cole o c\u00f3digo em um arquivo .cfm para testar. Encrypt Example \/* GenerateSecretKey does not generate key for the CFMX_COMPAT algorithm, so use the key from the form. *\/ if (Form.myAlgorithm EQ &#8220;CFMX_COMPAT&#8221;) theKey=Form.MyKey; \/\/ For all other encryption techniques, generate a secret key. else theKey=generateSecretKey(Form.myAlgorithm); \/\/Encrypt the string encrypted=encrypt(Form.myString, theKey, Form.myAlgorithm, Form.myEncoding); \/\/Decrypt it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[443],"tags":[520,510,444],"class_list":["post-1075","post","type-post","status-publish","format-standard","hentry","category-coldfusion","tag-adobe","tag-cf","tag-coldfusion-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\r\n<title>Exemplo encrypt\/decrypt em ColdFusion - Franklin Jr.<\/title>\r\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/www.franklinjr.com\/blog\/index.php\/2013\/11\/11\/exemplo-encryptdecrypt-em-coldfusion\/\" \/>\r\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.franklinjr.com\\\/blog\\\/index.php\\\/2013\\\/11\\\/11\\\/exemplo-encryptdecrypt-em-coldfusion\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/www.franklinjr.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exemplo encrypt\\\/decrypt em ColdFusion\"}]}]}<\/script>\r\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exemplo encrypt\/decrypt em ColdFusion - Franklin Jr.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.franklinjr.com\/blog\/index.php\/2013\/11\/11\/exemplo-encryptdecrypt-em-coldfusion\/","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"BreadcrumbList","@id":"https:\/\/www.franklinjr.com\/blog\/index.php\/2013\/11\/11\/exemplo-encryptdecrypt-em-coldfusion\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/www.franklinjr.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Exemplo encrypt\/decrypt em ColdFusion"}]}]}},"_links":{"self":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1075","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1075"}],"version-history":[{"count":5,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1075\/revisions"}],"predecessor-version":[{"id":1081,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1075\/revisions\/1081"}],"wp:attachment":[{"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1075"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1075"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.franklinjr.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1075"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}