Home » » mcrypt_encrypt

mcrypt_encrypt

Written By 1 on Monday, October 1, 2012 | 6:19 PM

string mcrypt_encrypt ( string $cipher , string $key , string $data , string $mode [, string $iv ] )

Encrypts plaintext with given parameters

Encrypts the data and returns it.


<?php
    $iv_size 
= mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
    
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
    
$key = "This is a very secret key";
    
$text = "Meet me at 11 o'clock behind the monument.";
    echo 
strlen($text) . "\n";

    
$crypttext = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $key, $text, MCRYPT_MODE_ECB, $iv);
    echo 
strlen($crypttext) . "\n";
?>


0 Comment:

Post a Comment