note 124491 added to function.str-pad

From: Date: Sat, 07 Dec 2019 18:53:09 +0000
Subject: note 124491 added to function.str-pad
Groups: php.notes 
Request: Send a blank email to php-notes+get-213418@lists.php.net to get a copy of this message
str_pad() can provide sufficient "zero padding" when using block ciphers and manual padding with openssl_encrypt() and similar. The example below will pad the 6 character text "Secret" with two \x00 characters and return 8 characters of data. Substitute your plain text and block size as needed. <?php $text = "Secret"; $block_size = 8; $length = ceil(strlen($text) / $block_size) * $block_size; $data = str_pad($text, $length, "\x00"); ---- Server IP: 208.43.231.9 Probable Submitter: 82.199.157.54 (proxied: 173.218.96.228) ---- Manual Page -- http://php.net/manual/en/function.str-pad.php Edit -- https://master.php.net/note/edit/124491 Del: integrated -- https://master.php.net/note/delete/124491/integrated Del: useless -- https://master.php.net/note/delete/124491/useless Del: bad code -- https://master.php.net/note/delete/124491/bad+code Del: spam -- https://master.php.net/note/delete/124491/spam Del: non-english -- https://master.php.net/note/delete/124491/non-english Del: in docs -- https://master.php.net/note/delete/124491/in+docs Del: other reasons-- https://master.php.net/note/delete/124491 Reject -- https://master.php.net/note/reject/124491 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#213418) next »