note 83519 added to ref.mcrypt

From: Date: Thu, 29 May 2008 19:25:48 +0000
Subject: note 83519 added to ref.mcrypt
Groups: php.notes 
Request: Send a blank email to php-notes+get-139986@lists.php.net to get a copy of this message
And some code for LM hash: <?php function LMhash($string) { $string = strtoupper(substr($string,0,14)); $p1 = LMhash_DESencrypt(substr($string, 0, 7)); $p2 = LMhash_DESencrypt(substr($string, 7, 7)); return strtoupper($p1.$p2); } function LMhash_DESencrypt($string) { $key = array(); $tmp = array(); $len = strlen($string); for ($i=0; $i<7; ++$i) $tmp[] = $i < $len ? ord($string[$i]) : 0; $key[] = $tmp[0] & 254; $key[] = ($tmp[0] << 7) | ($tmp[1] >> 1); $key[] = ($tmp[1] << 6) | ($tmp[2] >> 2); $key[] = ($tmp[2] << 5) | ($tmp[3] >> 3); $key[] = ($tmp[3] << 4) | ($tmp[4] >> 4); $key[] = ($tmp[4] << 3) | ($tmp[5] >> 5); $key[] = ($tmp[5] << 2) | ($tmp[6] >> 6); $key[] = $tmp[6] << 1; $is = mcrypt_get_iv_size(MCRYPT_DES, MCRYPT_MODE_ECB); $iv = mcrypt_create_iv($is, MCRYPT_RAND); $key0 = ""; foreach ($key as $k) $key0 .= chr($k); $crypt = mcrypt_encrypt(MCRYPT_DES, $key0, "KGS!@#$%", MCRYPT_MODE_ECB, $iv); return bin2hex($crypt); } ?> Some optimization? ---- Server IP: 193.233.48.78 (proxied: 193.233.51.120) Probable Submitter: 77.223.78.76 ---- Manual Page -- http://www.php.net/manual/en/ref.mcrypt.php Edit -- https://master.php.net/note/edit/83519 Del: integrated -- https://master.php.net/note/delete/83519/integrated Del: useless -- https://master.php.net/note/delete/83519/useless Del: bad code -- https://master.php.net/note/delete/83519/bad+code Del: spam -- https://master.php.net/note/delete/83519/spam Del: non-english -- https://master.php.net/note/delete/83519/non-english Del: in docs -- https://master.php.net/note/delete/83519/in+docs Del: other reasons-- https://master.php.net/note/delete/83519 Reject -- https://master.php.net/note/reject/83519 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#139986) next »