From 93ae4acaab77af9322516206696a89f527a34eef Mon Sep 17 00:00:00 2001 From: Derick Rethans Date: Fri, 25 Apr 2003 18:57:28 +0000 Subject: [PATCH] - Integrate another note git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@124639 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/mcrypt/functions/mcrypt-generic.xml | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/reference/mcrypt/functions/mcrypt-generic.xml b/reference/mcrypt/functions/mcrypt-generic.xml index 950961f441..9b7da2be54 100644 --- a/reference/mcrypt/functions/mcrypt-generic.xml +++ b/reference/mcrypt/functions/mcrypt-generic.xml @@ -1,5 +1,5 @@ - + @@ -20,6 +20,24 @@ of the returned string can in fact be longer then the input, due to the padding of the data. + + If you want to store the encrypted data in a database make sure to store + the entire string as returned by mcrypt_generic, or the string will not + entirely decrypt properly. If your original string is 10 characters long + and the block size is 8 (use + mcrypt_enc_get_block_size to determine the + blocksize), you would need at least 16 characters in your database field. + Note the string returned by mdecrypt_generic will be + 16 characters as well...use rtrim($str, "\0") to + remove the padding. + + + If you are for example storing the data in a MySQL database remember tha + varchar fields automatically have trailing spaces removed during + insertion. As encrypted data can end in a space (ASCII 32), the data will + be damaged by this removal. Store data in a tinyblob/tinytext (or + larger) field instead. + The encryption handle should always be initialized with mcrypt_generic_init with a key and an IV before