note 68082 added to function.mcrypt-generic
| From: | chad0x40herballure0x2ecom at osu1 dot php dot net | Date: | Wed, 12 Jul 2006 14:36:10 +0000 |
| Subject: | note 68082 added to function.mcrypt-generic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-114697@lists.php.net to get a copy of this message | ||
If the data is already n*blocksize long, PHP pads with another full block of "\0", so
there will be between 1 and mcrypt_enc_get_block_size($td) bytes of padding.
You can create binary-safe padding by unconditionally adding a 0x80 to the string, then stripping
trailing "\0"s PHP added, plus the one 0x80 byte.
<?php
function pad($text) {
// Add a single 0x80 byte and let PHP pad with 0x00 bytes.
return pack("a*H2", $text, "80");
}
function unpad($text) {
// Return all but the trailing 0x80 from text that had the 0x00 bytes removed
return substr(rtrim($text, "\0"), 0, -1);
}
?>
----
Server IP: 64.71.164.2
Probable Submitter: 69.205.153.76
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.mcrypt-generic.php
Edit -- http://master.php.net/note/edit/68082
Del: integrated -- http://master.php.net/note/delete/68082/integrated
Del: useless -- http://master.php.net/note/delete/68082/useless
Del: bad code -- http://master.php.net/note/delete/68082/bad+code
Del: spam -- http://master.php.net/note/delete/68082/spam
Del: non-english -- http://master.php.net/note/delete/68082/non-english
Del: in docs -- http://master.php.net/note/delete/68082/in+docs
Del: other reasons-- http://master.php.net/note/delete/68082
Reject -- http://master.php.net/note/reject/68082
Search -- http://master.php.net/manage/user-notes.php