Skip to content

Instantly share code, notes, and snippets.

@emayk
Created December 26, 2013 04:25
Show Gist options
  • Save emayk/8129760 to your computer and use it in GitHub Desktop.
Save emayk/8129760 to your computer and use it in GitHub Desktop.
crypt exampl 2
<?php
//Listing 3: Encrypting Data Using the mcrypt_ecb Function
// source http://stackoverflow.com/questions/16600708/php-string-encrypt-and-decrypt
echo("<h3> Symmetric Encryption </h3>");
$key_value = "KEYVALUE";
$plain_text = "PLAINTEXT";
$encrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $plain_text, MCRYPT_ENCRYPT);
echo ("<p><b> Text after encryption : </b>");
echo ( $encrypted_text );
$decrypted_text = mcrypt_ecb(MCRYPT_DES, $key_value, $encrypted_text, MCRYPT_DECRYPT);
echo ("<p><b> Text after decryption : </b>");
echo ( $decrypted_text );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment