note 67534 deleted from function.md5 by bjori

From: Date: Sat, 26 Aug 2006 11:31:59 +0000
Subject: note 67534 deleted from function.md5 by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116353@lists.php.net to get a copy of this message
Note Submitter: endeveit at pisem dot net ---- 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)" ?>

« previous php.notes (#116353) next »