FuryCell Posted December 30, 2005 Author Posted December 30, 2005 (edited) Yes. It appears that when your run SHA1Deep from the command line without parameters it lets you give it a string of text and then returns the SHA1. I will try and make a respective string counterparts to my _FileHash functions. Edited March 26, 2006 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
FuryCell Posted December 30, 2005 Author Posted December 30, 2005 (edited) OK. here is what i have so far. I will add the functions for others hashes tommorow add headers and then offically release them. Example: $Return=_StringHashSHA1("TEST") MsgBox(0,@Error,$Return) Note: Don't forget to download the SHA1Deep command line app to be able to use this func. I have attached it but you can also download it at the link on the first post.SHA1.au3sha1deep.zip Edited December 30, 2005 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
pingpong24 Posted December 30, 2005 Posted December 30, 2005 thanks very much, it works very good. this is what i was working on, if anyone is intrested they can finish the project of: this is a php implementation of SHA1 expandcollapse popup<?php /* ** Date modified: 1st October 2004 20:09 GMT * ** PHP implementation of the Secure Hash Algorithm ( SHA-1 ) * ** This code is available under the GNU Lesser General Public License: ** http://www.gnu.org/licenses/lgpl.txt * ** Based on the PHP implementation by Marcus Campbell ** http://www.tecknik.net/sha-1/ * ** This is a slightly modified version by me Jerome Clarke ( sinatosk@gmail.com ) ** because I feel more comfortable with this */ function sha1_str2blks_SHA1($str) { $strlen_str = strlen($str); $nblk = (($strlen_str + 8) >> 6) + 1; for ($i=0; $i < $nblk * 16; $i++) $blks[$i] = 0; for ($i=0; $i < $strlen_str; $i++) { $blks[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8); } $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); $blks[$nblk * 16 - 1] = $strlen_str * 8; return $blks; } function sha1_safe_add($x, $y) { $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); return ($msw << 16) | ($lsw & 0xFFFF); } function sha1_rol($num, $cnt) { return ($num << $cnt) | sha1_zeroFill($num, 32 - $cnt); } function sha1_zeroFill($a, $b) { $bin = decbin($a); $strlen_bin = strlen($bin); $bin = $strlen_bin < $b ? 0 : substr($bin, 0, $strlen_bin - $b); for ($i=0; $i < $b; $i++) $bin = '0'.$bin; return bindec($bin); } function sha1_ft($t, $b, $c, $d) { if ($t < 20) return ($b & $c) | ((~$b) & $d); if ($t < 40) return $b ^ $c ^ $d; if ($t < 60) return ($b & $c) | ($b & $d) | ($c & $d); return $b ^ $c ^ $d; } function sha1_kt($t) { if ($t < 20) return 1518500249; if ($t < 40) return 1859775393; if ($t < 60) return -1894007588; return -899497514; } function _sha1($str, $raw_output=FALSE) { if ( $raw_output === TRUE ) return pack('H*', sha1($str, FALSE)); $x = sha1_str2blks_SHA1($str); $a = 1732584193; $b = -271733879; $c = -1732584194; $d = 271733878; $e = -1009589776; $x_count = count($x); for ($i = 0; $i < $x_count; $i += 16) { $olda = $a; $oldb = $b; $oldc = $c; $oldd = $d; $olde = $e; for ($j = 0; $j < 80; $j++) { $w[$j] = ($j < 16) ? $x[$i + $j] : sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); $t = sha1_safe_add(sha1_safe_add(sha1_rol($a, 5), sha1_ft($j, $b, $c, $d)), sha1_safe_add(sha1_safe_add($e, $w[$j]), sha1_kt($j))); $e = $d; $d = $c; $c = sha1_rol($b, 30); $b = $a; $a = $t; } $a = sha1_safe_add($a, $olda); $b = sha1_safe_add($b, $oldb); $c = sha1_safe_add($c, $oldc); $d = sha1_safe_add($d, $oldd); $e = sha1_safe_add($e, $olde); } return sprintf('%08x%08x%08x%08x%08x', $a, $b, $c, $d, $e); } ?> All you have to do is chang eall the syntax to autoit and it will work expandcollapse popup#cs /* ** Date modified: 1st October 2004 20:09 GMT * ** PHP implementation of the Secure Hash Algorithm ( SHA-1 ) * ** This code is available under the GNU Lesser General Public License: ** http://www.gnu.org/licenses/lgpl.txt * ** Based on the PHP implementation by Marcus Campbell ** http://www.tecknik.net/sha-1/ * ** This is a slightly modified version by me Jerome Clarke ( sinatosk@gmail.com ) ** because I feel more comfortable with this */ #ce Func sha1_str2blks_SHA1($str) $strlen_str = StringLen($str); $nblk = BitShift(($strlen_str + 8), 6) + 1; For ($i=0 $i < $nblk * 16 $i++) $blks[$i] = 0 Next For $i=0 $i < $strlen_str $i++ $blks[BitShift ($i, 2)] |= Asc(StringInStr(BitShift (($str, $i, 1), (24 - (Mod($i, 4))) * 8))) Next $blks[BitShift ( $i, 2)] BitOR= BitShift (0x80 , (24 - (Mod ($i, 4)) * 8)) $blks[$nblk * 16 - 1] = $strlen_str * 8 return $blks EndFunc Func sha1_safe_add($x, $y) $lsw = ($x & 0xFFFF) + ($y & 0xFFFF) $msw = (BitShift($x , 16)) + (BitShift($y, 16)) + (BitShift($lsw, 16)) return (BitShift($msw, 16)) BitOR ($lsw & 0xFFFF); EndFunc Func sha1_rol($num, $cnt) return (BitShift($num, $cnt)) Or sha1_zeroFill($num, 32 - $cnt); EndFunc Func sha1_zeroFill($a, $b) $bin = decbin($a); $strlen_bin = StringLen($bin); $bin = $strlen_bin < $b ? 0 : StringInStr($bin, 0, $strlen_bin - $b); For ($i=0 $i < $b $i++) $bin = '0'.$bin return bindec($bin); EndFunc Func sha1_ft($t, $b, $c, $d) if ($t < 20) return ($b & $c) BitOR ((~$b) & $d) if ($t < 40) return $b ^ $c ^ $d if ($t < 60) return ($b & $c) BitOR ($b & $d) BitOR ($c & $d) return $b ^ $c ^ $d EndFunc Func sha1_kt($t) if ($t < 20) return 1518500249; if ($t < 40) return 1859775393; if ($t < 60) return -1894007588; return -899497514; EndFunc Func sha1($str, $raw_output=FALSE) if ( $raw_output == TRUE ) return pack('H*', sha1($str, FALSE)); $x = sha1_str2blks_SHA1($str); $a = 1732584193; $b = -271733879; $c = -1732584194; $d = 271733878; $e = -1009589776; $x_count = count($x); For $i = 0 $i < $x_count $i += 16 $olda = $a; $oldb = $b; $oldc = $c; $oldd = $d; $olde = $e; Next For ($j = 0 $j < 80 $j++) $w[$j] = ($j < 16) ? $x[$i + $j] : sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); $t = sha1_safe_add(sha1_safe_add(sha1_rol($a, 5), sha1_ft($j, $b, $c, $d)), sha1_safe_add(sha1_safe_add($e, $w[$j]), sha1_kt($j))); $e = $d; $d = $c; $c = sha1_rol($b, 30); $b = $a; $a = $t; $a = sha1_safe_add($a, $olda); $b = sha1_safe_add($b, $oldb); $c = sha1_safe_add($c, $oldc); $d = sha1_safe_add($d, $oldd); $e = sha1_safe_add($e, $olde); Next return sprintf('%08x%08x%08x%08x%08x', $a, $b, $c, $d, $e); EndFunc i done most of the code changes besides bitwiseOR part as i wasnt sure how many places you have to move a bit when you do >> or << in php and i havnt converted |= as i have no clude that stands for, and its not even documented in php documentation. rest is easy.. NumCR Super Fast EASY NUMBER OCR, easiest and the fastest AUTOIT OCR released on this forum
FuryCell Posted January 1, 2006 Author Posted January 1, 2006 (edited) thanks very much, it works very good. this is what i was working on, if anyone is intrested they can finish the project of: this is a php implementation of SHA1 expandcollapse popup<?php /* ** Date modified: 1st October 2004 20:09 GMT * ** PHP implementation of the Secure Hash Algorithm ( SHA-1 ) * ** This code is available under the GNU Lesser General Public License: ** http://www.gnu.org/licenses/lgpl.txt * ** Based on the PHP implementation by Marcus Campbell ** http://www.tecknik.net/sha-1/ * ** This is a slightly modified version by me Jerome Clarke ( sinatosk@gmail.com ) ** because I feel more comfortable with this */ function sha1_str2blks_SHA1($str) { $strlen_str = strlen($str); $nblk = (($strlen_str + 8) >> 6) + 1; for ($i=0; $i < $nblk * 16; $i++) $blks[$i] = 0; for ($i=0; $i < $strlen_str; $i++) { $blks[$i >> 2] |= ord(substr($str, $i, 1)) << (24 - ($i % 4) * 8); } $blks[$i >> 2] |= 0x80 << (24 - ($i % 4) * 8); $blks[$nblk * 16 - 1] = $strlen_str * 8; return $blks; } function sha1_safe_add($x, $y) { $lsw = ($x & 0xFFFF) + ($y & 0xFFFF); $msw = ($x >> 16) + ($y >> 16) + ($lsw >> 16); return ($msw << 16) | ($lsw & 0xFFFF); } function sha1_rol($num, $cnt) { return ($num << $cnt) | sha1_zeroFill($num, 32 - $cnt); } function sha1_zeroFill($a, $b) { $bin = decbin($a); $strlen_bin = strlen($bin); $bin = $strlen_bin < $b ? 0 : substr($bin, 0, $strlen_bin - $b); for ($i=0; $i < $b; $i++) $bin = '0'.$bin; return bindec($bin); } function sha1_ft($t, $b, $c, $d) { if ($t < 20) return ($b & $c) | ((~$b) & $d); if ($t < 40) return $b ^ $c ^ $d; if ($t < 60) return ($b & $c) | ($b & $d) | ($c & $d); return $b ^ $c ^ $d; } function sha1_kt($t) { if ($t < 20) return 1518500249; if ($t < 40) return 1859775393; if ($t < 60) return -1894007588; return -899497514; } function _sha1($str, $raw_output=FALSE) { if ( $raw_output === TRUE ) return pack('H*', sha1($str, FALSE)); $x = sha1_str2blks_SHA1($str); $a = 1732584193; $b = -271733879; $c = -1732584194; $d = 271733878; $e = -1009589776; $x_count = count($x); for ($i = 0; $i < $x_count; $i += 16) { $olda = $a; $oldb = $b; $oldc = $c; $oldd = $d; $olde = $e; for ($j = 0; $j < 80; $j++) { $w[$j] = ($j < 16) ? $x[$i + $j] : sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); $t = sha1_safe_add(sha1_safe_add(sha1_rol($a, 5), sha1_ft($j, $b, $c, $d)), sha1_safe_add(sha1_safe_add($e, $w[$j]), sha1_kt($j))); $e = $d; $d = $c; $c = sha1_rol($b, 30); $b = $a; $a = $t; } $a = sha1_safe_add($a, $olda); $b = sha1_safe_add($b, $oldb); $c = sha1_safe_add($c, $oldc); $d = sha1_safe_add($d, $oldd); $e = sha1_safe_add($e, $olde); } return sprintf('%08x%08x%08x%08x%08x', $a, $b, $c, $d, $e); } ?> All you have to do is chang eall the syntax to autoit and it will work expandcollapse popup#cs /* ** Date modified: 1st October 2004 20:09 GMT * ** PHP implementation of the Secure Hash Algorithm ( SHA-1 ) * ** This code is available under the GNU Lesser General Public License: ** http://www.gnu.org/licenses/lgpl.txt * ** Based on the PHP implementation by Marcus Campbell ** http://www.tecknik.net/sha-1/ * ** This is a slightly modified version by me Jerome Clarke ( sinatosk@gmail.com ) ** because I feel more comfortable with this */ #ce Func sha1_str2blks_SHA1($str) $strlen_str = StringLen($str); $nblk = BitShift(($strlen_str + 8), 6) + 1; For ($i=0 $i < $nblk * 16 $i++) $blks[$i] = 0 Next For $i=0 $i < $strlen_str $i++ $blks[BitShift ($i, 2)] |= Asc(StringInStr(BitShift (($str, $i, 1), (24 - (Mod($i, 4))) * 8))) Next $blks[BitShift ( $i, 2)] BitOR= BitShift (0x80 , (24 - (Mod ($i, 4)) * 8)) $blks[$nblk * 16 - 1] = $strlen_str * 8 return $blks EndFunc Func sha1_safe_add($x, $y) $lsw = ($x & 0xFFFF) + ($y & 0xFFFF) $msw = (BitShift($x , 16)) + (BitShift($y, 16)) + (BitShift($lsw, 16)) return (BitShift($msw, 16)) BitOR ($lsw & 0xFFFF); EndFunc Func sha1_rol($num, $cnt) return (BitShift($num, $cnt)) Or sha1_zeroFill($num, 32 - $cnt); EndFunc Func sha1_zeroFill($a, $b) $bin = decbin($a); $strlen_bin = StringLen($bin); $bin = $strlen_bin < $b ? 0 : StringInStr($bin, 0, $strlen_bin - $b); For ($i=0 $i < $b $i++) $bin = '0'.$bin return bindec($bin); EndFunc Func sha1_ft($t, $b, $c, $d) if ($t < 20) return ($b & $c) BitOR ((~$b) & $d) if ($t < 40) return $b ^ $c ^ $d if ($t < 60) return ($b & $c) BitOR ($b & $d) BitOR ($c & $d) return $b ^ $c ^ $d EndFunc Func sha1_kt($t) if ($t < 20) return 1518500249; if ($t < 40) return 1859775393; if ($t < 60) return -1894007588; return -899497514; EndFunc Func sha1($str, $raw_output=FALSE) if ( $raw_output == TRUE ) return pack('H*', sha1($str, FALSE)); $x = sha1_str2blks_SHA1($str); $a = 1732584193; $b = -271733879; $c = -1732584194; $d = 271733878; $e = -1009589776; $x_count = count($x); For $i = 0 $i < $x_count $i += 16 $olda = $a; $oldb = $b; $oldc = $c; $oldd = $d; $olde = $e; Next For ($j = 0 $j < 80 $j++) $w[$j] = ($j < 16) ? $x[$i + $j] : sha1_rol($w[$j - 3] ^ $w[$j - 8] ^ $w[$j - 14] ^ $w[$j - 16], 1); $t = sha1_safe_add(sha1_safe_add(sha1_rol($a, 5), sha1_ft($j, $b, $c, $d)), sha1_safe_add(sha1_safe_add($e, $w[$j]), sha1_kt($j))); $e = $d; $d = $c; $c = sha1_rol($b, 30); $b = $a; $a = $t; $a = sha1_safe_add($a, $olda); $b = sha1_safe_add($b, $oldb); $c = sha1_safe_add($c, $oldc); $d = sha1_safe_add($d, $oldd); $e = sha1_safe_add($e, $olde); Next return sprintf('%08x%08x%08x%08x%08x', $a, $b, $c, $d, $e); EndFunc i done most of the code changes besides bitwiseOR part as i wasnt sure how many places you have to move a bit when you do >> or << in php and i havnt converted |= as i have no clude that stands for, and its not even documented in php documentation. rest is easy.. thanks for the feedback. almost ready to release the final versions of the String counterparts for my _FileHash functions. Edit:_StringHash() is now avalible.look in my sig. Edited March 26, 2006 by SolidSnake HKTunes:Softpedia | GoogleCodeLyricToy:Softpedia | GoogleCodeRCTunes:Softpedia | GoogleCodeMichtaToolsProgrammer n. - An ingenious device that turns caffeine into code.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now