Archive for novembro de 2013

Exemplo encrypt/decrypt em ColdFusion

novembro 11th, 2013

Cole o código em um arquivo .cfm para testar.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<h3>Encrypt Example</h3> 
<!--- Do the following if the form has been submitted. ---> 
<cfif IsDefined("Form.myString")> 
    <cfscript> 
        /* GenerateSecretKey does not generate key for the CFMX_COMPAT algorithm, 
        so use the key from the form. 
        */ 
        if (Form.myAlgorithm EQ "CFMX_COMPAT") 
            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 
        decrypted=decrypt(encrypted, theKey, Form.myAlgorithm, Form.myEncoding); 
    </cfscript> 
 
    <!--- Display the values used for encryption and decryption,  
            and the results. ---> 
    <cfoutput> 
        <b>The algorithm:</b> #Form.myAlgorithm#<br> 
        <b>The key:</B> #theKey#<br> 
        <br> 
        <b>The string:</b> #Form.myString# <br> 
        <br> 
        <b>Encrypted:</b> #encrypted#<br> 
        <br> 
        <b>Decrypted:</b> #decrypted#<br> 
    </cfoutput> 
</cfif> 
 
<!--- The input form.---> 
<form action="#CGI.SCRIPT_NAME#" method="post"> 
    <b>Select the encoding</b><br> 
    <select size="1" name="myEncoding"> 
        <option selected>UU</option> 
        <option>Base64</option> 
        <option>Hex</option> 
    </select><br> 
    <br> 
    <b>Select the algorithm</b><br> 
    <select size="1" name="myAlgorithm"> 
        <option selected>CFMX_COMPAT</option> 
        <option>AES</option> 
        <option>DES</option> 
        <option>DESEDE</option> 
    </select><br> 
    <br> 
    <b>Input your key</b> (used for CFMX_COMPAT encryption only)<br> 
    <input type = "Text" name = "myKey" value = "MyKey"><br> 
    <br> 
    <b>Enter string to encrypt</b><br> 
    <textArea name = "myString" cols = "40" rows = "5" WRAP = "VIRTUAL">This string will be encrypted (you can replace it with more typing). 
    </textArea><br> 
    <input type = "Submit" value = "Encrypt my String"> 
</form>

Retirado daqui

Lomba Beverly Hills em Porto Alegre

novembro 6th, 2013

A lomba/ladeira Beverly Hills em Porto Alegre, ideal para a modalidade de skate downhill, fica aqui

Exibir mapa ampliado