note 67534 added to function.md5

From: Date: Thu, 08 Jun 2006 17:28:11 +0000
Subject: note 67534 added to function.md5
Groups: php.notes 
Request: Send a blank email to php-notes+get-113871@lists.php.net to get a copy of this message
Some peoples (e.g. who keep password in MySQL) worry about memory occupied by string with 32 symbols. I don't understand them, however i wrote function which returns integer representation of encrypted md5's string. 8 bytes of integer less than 32*8 bytes of varchar ;) <?php /** * This function encrypt string $pwd with MD5, * reverse given hash and return an integer * representation of it. * * @param string $pwd * @return int */ function encryptPwdToInt($pwd) { $enc = strrev(md5($pwd)); $enc = preg_replace("/([^[:digit:]])/i", '', $enc); return (int) sprintf('%u', round((substr($enc, 0, 9)/round(substr($enc, 10, 2)))*2)); } var_dump(encryptPwdToInt('some_pwd_string')); //returns "int(401309)" ?> ---- Server IP: 195.222.164.18 Probable Submitter: 217.195.69.69 ---- 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.md5.php Edit -- http://master.php.net/note/edit/67534 Del: integrated -- http://master.php.net/note/delete/67534/integrated Del: useless -- http://master.php.net/note/delete/67534/useless Del: bad code -- http://master.php.net/note/delete/67534/bad+code Del: spam -- http://master.php.net/note/delete/67534/spam Del: non-english -- http://master.php.net/note/delete/67534/non-english Del: in docs -- http://master.php.net/note/delete/67534/in+docs Del: other reasons-- http://master.php.net/note/delete/67534 Reject -- http://master.php.net/note/reject/67534 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#113871) next »