createIV(PHP_Crypt::RAND); // The default, uses PHP's mt_rand() * $iv = $crypt->createIV(PHP_Crypt::RAND_DEV_RAND); // unix only, uses /dev/random * $iv = $crypt->createIV(PHP_Crypt::RAND_DEV_URAND);// unix only, uses /dev/urandom * $iv = $crypt->createIV(PHP_Crypt::RAND_WIN_COM); // Windows only, uses the com_dotnet extension * * In the case where you are given an encrypted string, along with the key and IV * to decrypt the string, you don't need to call createIV() since the IV has already * been created for you. Set the IV by calling $crypt->IV($iv) as shown below. */ // by default createIV() uses PHP_Crypt::RAND which uses PHP's mt_rand() $iv = $crypt->createIV(); $encrypt = $crypt->encrypt($text); // we need to use the same IV for decryption as used during encryption $crypt->IV($iv); $decrypt = $crypt->decrypt($encrypt); print "CIPHER: ".$crypt->cipherName()."\n"; print "MODE: ".$crypt->modeName()."\n"; print "PLAIN TEXT: $text\n"; print "PLAIN TEXT HEX: ".bin2hex($text)."\n"; print "ENCRYPTED HEX: ".bin2hex($encrypt)."\n"; print "DECRYPTED: $decrypt\n"; print "DECRYPTED HEX: ".bin2hex($decrypt)."\n"; ?>