Search
Archives
- August 2015 (1)
- September 2014 (1)
- June 2014 (2)
- January 2014 (1)
- September 2012 (1)
- July 2012 (1)
- April 2012 (1)
- January 2012 (2)
- June 2011 (2)
- November 2010 (1)
- October 2010 (1)
- May 2010 (2)
- April 2010 (1)
- December 2009 (1)
- November 2009 (1)
- August 2009 (1)
- June 2009 (1)
- April 2009 (1)
- January 2009 (5)
- December 2008 (1)
- November 2008 (1)
- August 2008 (3)
- July 2008 (3)
- June 2008 (1)
- February 2008 (2)
- January 2008 (1)
- November 2007 (2)
- September 2007 (1)
- July 2007 (1)
- May 2007 (2)
Categories
Meta
Monthly Archives: June 2014
WebPasswd
WebPasswd is a password app that I have been working on, its a self hosted PHP app, that stores usernames and password (along with notes) in an encrypted file.
I’ve released it under the MIT license and available on github at https://github.com/sam159/WebPasswd
PKCS#5 Padding with PHP
Here is a quick class for dealing with PKCS#5 style padding.
This padding is useful for encrypting data with DES/AES which have a multi-byte block size. MCrypt will by default pad out to the next block boundary with Null bytes which will show up in the decrypted data.
A good explanation can be found here.
class PKCS5Padding { public static function Pad($unpaddedString, $blockSize) { $additionalChars = $blockSize - strlen($unpaddedString) % $blockSize; $char = chr($additionalChars); return $unpaddedString.str_repeat($char, $additionalChars); } public static function UnPad($paddedString) { $additionalChars = ord(substr($paddedString, -1, 1)); return substr($paddedString, 0, -$additionalChars); } } //Example use. $td is the resource returned by mcrypt_module_open $paddedData = PKCS5Padding::Pad($data, mcrypt_enc_get_block_size($td));