mcrypt_encrypt

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
abalfazl
Forum Commoner
Posts: 71
Joined: Mon Sep 05, 2005 10:05 pm

mcrypt_encrypt

Post by abalfazl »

Hi

Description
int mcrypt_get_iv_size ( string $cipher , string $mode )

mcrypt_get_iv_size() returns the size of the Initialisation Vector (IV) in bytes. On error the function returns FALSE. If the IV is ignored in the specified cipher/mode combination zero is returned.
1-What is Initialisation Vector (IV)?


PHP Code:

Code: Select all

 
<?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";
?>
 

Code: Select all

 
2-What does $iv_size do?why does it use mcrypt_create_iv($iv_size, MCRYPT_RAND); ???

Anyone can explain about mechanism of encryption in PHP?


Do you know good tutorial for that?
Post Reply