Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Even more scripts

  • Loading branch information...
commit cc5afaa2d8c934b4a23a3b55df063d526a181475 1 parent c4ee454
Elliott Kember authored
View
32 actionscript/actionscript-ryan-rapp.as
@@ -0,0 +1,32 @@
+public function runTests():void
+{
+ var isReversible:Boolean = false;
+ var count:int = 0;
+ while(!isReversible)
+ {
+ var test:String = random_gen(32);
+ count++;
+ if(count == 1000)
+ {
+ trace(test);
+ count = 0;
+ }
+
+ var hash:String = encrypt(test);
+ if(test == hash)
+ {
+ isReversible = true;
+ trace("We found it! " + test + " is a reversible md5 hash. Profit!");
+ }
+ }
+}
+
+private function random_gen(len:int):String
+{
+ var chars:String = "1234567890abcdef";
+ var str:String = "";
+ for(var i:int = 0; i < len; i++)
+ str += chars.charAt(Math.floor(Math.random() * chars.length));
+
+ return str;
+}
View
404 actionscript/actionscript-ryan-rapp2.as
@@ -0,0 +1,404 @@
+package
+{
+ import flash.display.Sprite;
+
+ public class Identity extends Sprite
+ {
+ public function Identity()
+ {
+ runTests();
+ }
+
+ public function runTests():void
+ {
+ var isReversible:Boolean = false;
+ var count:int = 0;
+ while(!isReversible)
+ {
+ var test:String = random_gen(32);
+ count++;
+ if(count == 1000)
+ {
+ trace(test);
+ count = 0;
+ }
+
+ var hash:String = encrypt(test);
+ if(test == hash)
+ {
+ isReversible = true;
+ trace("We found it! " + test + " is a reversible md5 hash. Profit!");
+ }
+ }
+ }
+
+ private function random_gen(len:int):String
+ {
+ var chars:String = "1234567890abcdef";
+ var str:String = "";
+ for(var i:int = 0; i < len; i++)
+ str += chars.charAt(Math.floor(Math.random() * chars.length));
+
+ return str;
+ }
+
+
+ /* Taken from http://gsolofp.blogspot.com/2006/01/actionscript-3-md5-and-sha1.html */
+
+ public static const HEX_FORMAT_LOWERCASE:uint = 0;
+ public static const HEX_FORMAT_UPPERCASE:uint = 1;
+
+ public static const BASE64_PAD_CHARACTER_DEFAULT_COMPLIANCE:String = "";
+ public static const BASE64_PAD_CHARACTER_RFC_COMPLIANCE:String = "=";
+
+ public static var hexcase:uint = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
+ public static var b64pad:String = ""; /* base-64 pad character. "=" for strict RFC compliance */
+
+ public static function encrypt (string:String):String {
+ return hex_md5 (string);
+ }
+
+ /*
+ * These are the functions you'll usually want to call
+ * They take string arguments and return either hex or base-64 encoded strings
+ */
+ public static function hex_md5 (string:String):String {
+ return rstr2hex (rstr_md5 (str2rstr_utf8 (string)));
+ }
+
+ public static function b64_md5 (string:String):String {
+ return rstr2b64 (rstr_md5 (str2rstr_utf8 (string)));
+ }
+
+ public static function any_md5 (string:String, encoding:String):String {
+ return rstr2any (rstr_md5 (str2rstr_utf8 (string)), encoding);
+ }
+ public static function hex_hmac_md5 (key:String, data:String):String {
+ return rstr2hex (rstr_hmac_md5 (str2rstr_utf8 (key), str2rstr_utf8 (data)));
+ }
+ public static function b64_hmac_md5 (key:String, data:String):String {
+ return rstr2b64 (rstr_hmac_md5 (str2rstr_utf8 (key), str2rstr_utf8 (data)));
+ }
+ public static function any_hmac_md5 (key:String, data:String, encoding:String):String {
+ return rstr2any(rstr_hmac_md5(str2rstr_utf8(key), str2rstr_utf8(data)), encoding);
+ }
+
+ /*
+ * Perform a simple self-test to see if the VM is working
+ */
+ public static function md5_vm_test ():Boolean {
+ return hex_md5 ("abc") == "900150983cd24fb0d6963f7d28e17f72";
+ }
+
+ /*
+ * Calculate the MD5 of a raw string
+ */
+ public static function rstr_md5 (string:String):String {
+ return binl2rstr (binl_md5 (rstr2binl (string), string.length * 8));
+ }
+
+ /*
+ * Calculate the HMAC-MD5, of a key and some data (raw strings)
+ */
+ public static function rstr_hmac_md5 (key:String, data:String):String {
+ var bkey:Array = rstr2binl (key);
+ if (bkey.length > 16) bkey = binl_md5 (bkey, key.length * 8);
+
+ var ipad:Array = Array(16), opad:Array = Array(16);
+ for(var i:Number = 0; i < 16; i++) {
+ ipad[i] = bkey[i] ^ 0x36363636;
+ opad[i] = bkey[i] ^ 0x5C5C5C5C;
+ }
+
+ var hash:Array = binl_md5 (ipad.concat (rstr2binl (data)), 512 + data.length * 8);
+ return binl2rstr (binl_md5 (opad.concat (hash), 512 + 128));
+ }
+
+ /*
+ * Convert a raw string to a hex string
+ */
+ public static function rstr2hex (input:String):String {
+ var hex_tab:String = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
+ var output:String = "";
+ var x:Number;
+ for(var i:Number = 0; i < input.length; i++) {
+ x = input.charCodeAt(i);
+ output += hex_tab.charAt((x >>> 4) & 0x0F)
+ + hex_tab.charAt( x & 0x0F);
+ }
+ return output;
+ }
+
+ /*
+ * Convert a raw string to a base-64 string
+ */
+ public static function rstr2b64 (input:String):String {
+ var tab:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
+ var output:String = "";
+ var len:Number = input.length;
+ for(var i:Number = 0; i < len; i += 3) {
+ var triplet:Number = (input.charCodeAt(i) << 16)
+ | (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
+ | (i + 2 < len ? input.charCodeAt(i+2) : 0);
+ for(var j:Number = 0; j < 4; j++) {
+ if(i * 8 + j * 6 > input.length * 8) output += b64pad;
+ else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
+ }
+ }
+ return output;
+ }
+
+ /*
+ * Convert a raw string to an arbitrary string encoding
+ */
+ public static function rstr2any(input:String, encoding:String):String {
+ var divisor:Number = encoding.length;
+ var remainders:Array = [];
+ var i:Number, q:Number, x:Number, quotient:Array;
+
+ /* Convert to an array of 16-bit big-endian values, forming the dividend */
+ var dividend:Array = Array(input.length / 2);
+ for(i = 0; i < dividend.length; i++) {
+ dividend[i] = (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
+ }
+
+ /*
+ * Repeatedly perform a long division. The binary array forms the dividend,
+ * the length of the encoding is the divisor. Once computed, the quotient
+ * forms the dividend for the next step. We stop when the dividend is zero.
+ * All remainders are stored for later use.
+ */
+ while(dividend.length > 0) {
+ quotient = [];
+ x = 0;
+ for(i = 0; i < dividend.length; i++) {
+ x = (x << 16) + dividend[i];
+ q = Math.floor(x / divisor);
+ x -= q * divisor;
+ if(quotient.length > 0 || q > 0)
+ quotient[quotient.length] = q;
+ }
+ remainders[remainders.length] = x;
+ dividend = quotient;
+ }
+
+ /* Convert the remainders to the output string */
+ var output:String = "";
+ for(i = remainders.length - 1; i >= 0; i--)
+ output += encoding.charAt (remainders[i]);
+
+ return output;
+ }
+
+ /*
+ * Encode a string as utf-8.
+ * For efficiency, this assumes the input is valid utf-16.
+ */
+ public static function str2rstr_utf8 (input:String):String {
+ var output:String = "";
+ var i:Number = -1;
+ var x:Number, y:Number;
+
+ while(++i < input.length) {
+ /* Decode utf-16 surrogate pairs */
+ x = input.charCodeAt(i);
+ y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
+ if(0xD800 <= x && x <= 0xDBFF && 0xDC00 <= y && y <= 0xDFFF) {
+ x = 0x10000 + ((x & 0x03FF) << 10) + (y & 0x03FF);
+ i++;
+ }
+
+ /* Encode output as utf-8 */
+ if(x <= 0x7F)
+ output += String.fromCharCode(x);
+ else if(x <= 0x7FF)
+ output += String.fromCharCode(0xC0 | ((x >>> 6 ) & 0x1F),
+ 0x80 | ( x & 0x3F));
+ else if(x <= 0xFFFF)
+ output += String.fromCharCode(0xE0 | ((x >>> 12) & 0x0F),
+ 0x80 | ((x >>> 6 ) & 0x3F),
+ 0x80 | ( x & 0x3F));
+ else if(x <= 0x1FFFFF)
+ output += String.fromCharCode(0xF0 | ((x >>> 18) & 0x07),
+ 0x80 | ((x >>> 12) & 0x3F),
+ 0x80 | ((x >>> 6 ) & 0x3F),
+ 0x80 | ( x & 0x3F));
+ }
+ return output;
+ }
+
+ /*
+ * Encode a string as utf-16
+ */
+ public static function str2rstr_utf16le (input:String):String {
+ var output:String = "";
+ for(var i:Number = 0; i < input.length; i++)
+ output += String.fromCharCode( input.charCodeAt(i) & 0xFF,
+ (input.charCodeAt(i) >>> 8) & 0xFF);
+ return output;
+ }
+
+ public static function str2rstr_utf16be (input:String):String {
+ var output:String = "";
+ for(var i:Number = 0; i < input.length; i++)
+ output += String.fromCharCode((input.charCodeAt(i) >>> 8) & 0xFF,
+ input.charCodeAt(i) & 0xFF);
+ return output;
+ }
+
+ /*
+ * Convert a raw string to an array of little-endian words
+ * Characters >255 have their high-byte silently ignored.
+ */
+ public static function rstr2binl (input:String):Array {
+ var output:Array = Array(input.length >> 2);
+ for(var i:Number = 0; i < output.length; i++)
+ output[i] = 0;
+ for(var i:Number = 0; i < input.length * 8; i += 8)
+ output[i>>5] |= (input.charCodeAt(i / 8) & 0xFF) << (i%32);
+ return output;
+ }
+
+ /*
+ * Convert an array of little-endian words to a string
+ */
+ public static function binl2rstr (input:Array):String {
+ var output:String = "";
+ for(var i:Number = 0; i < input.length * 32; i += 8)
+ output += String.fromCharCode((input[i>>5] >>> (i % 32)) & 0xFF);
+ return output;
+ }
+
+ /*
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
+ */
+ public static function binl_md5 (x:Array, len:Number):Array {
+ /* append padding */
+ x[len >> 5] |= 0x80 << ((len) % 32);
+ x[(((len + 64) >>> 9) << 4) + 14] = len;
+
+ var a:Number = 1732584193;
+ var b:Number = -271733879;
+ var c:Number = -1732584194;
+ var d:Number = 271733878;
+
+ for(var i:Number = 0; i < x.length; i += 16) {
+ var olda:Number = a;
+ var oldb:Number = b;
+ var oldc:Number = c;
+ var oldd:Number = d;
+
+ a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
+ d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
+ c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
+ b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
+ a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
+ d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
+ c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
+ b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
+ a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
+ d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
+ c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
+ b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
+ a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
+ d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
+ c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
+ b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
+
+ a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
+ d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
+ c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
+ b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
+ a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
+ d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
+ c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
+ b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
+ a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
+ d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
+ c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
+ b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
+ a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
+ d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
+ c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
+ b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
+
+ a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
+ d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
+ c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
+ b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
+ a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
+ d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
+ c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
+ b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
+ a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
+ d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
+ c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
+ b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
+ a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
+ d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
+ c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
+ b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
+
+ a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
+ d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
+ c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
+ b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
+ a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
+ d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
+ c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
+ b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
+ a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
+ d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
+ c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
+ b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
+ a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
+ d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
+ c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
+ b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
+
+ a = safe_add(a, olda);
+ b = safe_add(b, oldb);
+ c = safe_add(c, oldc);
+ d = safe_add(d, oldd);
+ }
+ return [a, b, c, d];
+ }
+
+ /*
+ * These functions implement the four basic operations the algorithm uses.
+ */
+ public static function md5_cmn (q:Number, a:Number, b:Number, x:Number, s:Number, t:Number):Number {
+ return safe_add (bit_rol (safe_add (safe_add (a, q), safe_add(x, t)), s), b);
+ }
+ public static function md5_ff (a:Number, b:Number, c:Number, d:Number, x:Number, s:Number, t:Number):Number {
+ return md5_cmn ((b & c) | ((~b) & d), a, b, x, s, t);
+ }
+ public static function md5_gg (a:Number, b:Number, c:Number, d:Number, x:Number, s:Number, t:Number):Number {
+ return md5_cmn ((b & d) | (c & (~d)), a, b, x, s, t);
+ }
+ public static function md5_hh (a:Number, b:Number, c:Number, d:Number, x:Number, s:Number, t:Number):Number {
+ return md5_cmn (b ^ c ^ d, a, b, x, s, t);
+ }
+ public static function md5_ii (a:Number, b:Number, c:Number, d:Number, x:Number, s:Number, t:Number):Number {
+ return md5_cmn (c ^ (b | (~d)), a, b, x, s, t);
+ }
+
+ /*
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
+ * to work around bugs in some JS interpreters.
+ */
+ public static function safe_add (x:Number, y:Number):Number {
+ var lsw:Number = (x & 0xFFFF) + (y & 0xFFFF);
+ var msw:Number = (x >> 16) + (y >> 16) + (lsw >> 16);
+ return (msw << 16) | (lsw & 0xFFFF);
+ }
+
+ /*
+ * Bitwise rotate a 32-bit number to the left.
+ */
+ public static function bit_rol (num:Number, cnt:Number):Number {
+ return (num << cnt) | (num >>> (32 - cnt));
+ }
+
+ }
+}
View
41 coldfusion/coldfusion-Stephen-Withington.cf
@@ -0,0 +1,41 @@
+<!---
+ Page: getKemberIdentity.cfm
+ Author: Stephen J. Withington, Jr. (stephenwithington.com)
+ Version: 20090501.00
+ Purpose: Challenge to find a string that when hashed, will return itself.
+ See http://www.elliottkember.com/kember_identity.html for more information.
+--->
+
+<cffunction name="getKemberIdentity" access="public" output="false" returntype="string"
+ hint="I try to find a string that when hashed, will return itself.">
+ <cfargument name="timesToTry" type="numeric" required="true" />
+ <cfset var kemberResult = "" />
+ <cfset var theRandomString = "" />
+ <cfset var theHashedString = "" />
+ <cfset var theIndex = "" />
+ <cfloop index="theIndex" from="1" to="#val(arguments.timesToTry)#" step="1">
+ <cfset theRandomString = RandomizeString() />
+ <cfset theHashedString = hash(theRandomString, "MD5", "UTF-8") />
+ <cfif theHashedString eq theRandomString>
+ <cfset kemberResult = "We found a winner: #theRandomString# = #theHashedString# = JACKPOT!!!!" />
+ <cfreturn kemberResult />
+ <cfelseif theIndex eq timesToTry>
+ <cfset kemberResult = "." />
+ </cfif>
+ </cfloop>
+ <cfreturn kemberResult />
+</cffunction>
+
+<cffunction name="RandomizeString" access="public" output="false" returntype="string"
+ hint="pass me a string and desired length and I'll randomize it for you.">
+ <cfargument name="theString" type="string" required="false" default="0123456789ABCDEF" />
+ <cfargument name="theLength" type="numeric" required="false" default="32" />
+ <cfset var randomizedString = "" />
+ <cfset var theIndex = "" />
+ <cfloop index="theIndex" from="1" to="#val(arguments.theLength)#" step="1">
+ <cfset randomizedString = randomizedString & mid(arguments.theString, rand()*len(arguments.theString)+1, 1) />
+ </cfloop>
+ <cfreturn randomizedString />
+</cffunction>
+
+<cfoutput>#getKemberIdentity(100000)#</cfoutput>
View
84 cplusplus/cplusplus-Quinten-Lansu.cpp
@@ -0,0 +1,84 @@
+#include <iostream>
+#include <string> // string
+#include <ctime> // time()
+#include <cstdlib> // srand() and rand()
+#include "md5.h"
+#include "md5wrapper.h"
+
+char input[256];
+const char* cmpInput;
+std::string encInput;
+md5wrapper* encrypt;
+int i;
+unsigned long tries;
+
+int number;
+char newInput[32];
+
+char rndInput[16];
+
+int _tmain(int argc, _TCHAR* argv[])
+{
+ encrypt = new md5wrapper();
+
+ std::cout << "Enter a string (up to 256 characters) to get started. \n> ";
+ fgets(input, sizeof input, stdin);
+
+ number = -1;
+
+ // blah, there's probably a better way to do this
+ rndInput[0] = '0';
+ rndInput[1] = '1';
+ rndInput[2] = '2';
+ rndInput[3] = '3';
+ rndInput[4] = '4';
+ rndInput[5] = '5';
+ rndInput[6] = '6';
+ rndInput[7] = '7';
+ rndInput[8] = '8';
+ rndInput[9] = '9';
+ rndInput[10] = 'a';
+ rndInput[11] = 'b';
+ rndInput[12] = 'c';
+ rndInput[13] = 'd';
+ rndInput[14] = 'e';
+ rndInput[15] = 'f';
+
+ srand(time(0));
+
+ if (input != NULL)
+ {
+ while (1)
+ {
+ tries++;
+ encInput = encrypt->getHashFromString(input);
+ std::cout << "In: " << input << " Out: " << encInput << "\n";
+ cmpInput = encInput.c_str();
+
+ // comparison
+ for (i = 0; i < 32; i++) { if (cmpInput[i] != input[i]) { break; } }
+
+ if (i >= 32)
+ {
+ std::cout << "Holy shit! We found it! \n" << "And it only took " << tries << " tries!";
+ fgets(input, sizeof input, stdin);
+ }
+
+ // compile a new string from the other strings to help randomness
+ if (number++ == 32)
+ {
+ memcpy(input, newInput, 32 * sizeof(char));
+ number = -1;
+ }
+ else
+ {
+ int pick = rand() % 16;
+ newInput[number] = rndInput[pick];
+ strcpy(input, cmpInput);
+ }
+ }
+ }
+
+ return 0;
+}
+
View
60 csharp/csharp-Alx-West.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Text;
+using System.Security.Cryptography;
+
+
+namespace kemberHash
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+
+ bool isReversible=false ;
+ int i = 0;
+ while(!isReversible) {
+ string str = random_gen(32);
+ i++;
+ if (i == 10000) {
+ Console.WriteLine(str);
+ i = 0;
+ }
+ string output = getMD5Hash(str);
+
+
+ if(output == str) {
+ isReversible = true;
+ Console.WriteLine("Hurrah " + str + " is a reversible md5 hash. Profit!");
+ }
+ }
+
+ }
+
+ static string random_gen(int length)
+ {
+ string c = "0123456789abcdef";
+ string str = "";
+ Random r = new Random();
+ for(int i = 0; i<length ;i++)
+ {
+ str += c.Substring(r.Next(c.Length -1), 1);
+ }
+ return str;
+ }
+
+ static string getMD5Hash(string strToHash)
+ {
+
+ MD5CryptoServiceProvider md5Obj = new MD5CryptoServiceProvider();
+ byte[] bytesToHash = System.Text.Encoding.ASCII.GetBytes(strToHash);
+ bytesToHash = md5Obj.ComputeHash(bytesToHash);
+ string strResult = "";
+ foreach (byte b in bytesToHash)
+ {
+ strResult += b.ToString("x2");
+ }
+ return strResult;
+ }
+
+ }
+}
View
40 csharp/csharp-Jaco-Pretorius.cs
@@ -0,0 +1,40 @@
+/// <summary>
+/// A Kember Identity Hash script in C#
+/// by Jaco Pretorius
+/// </summary>
+
+using System;
+using System.Security.Cryptography;
+using System.Text;
+
+namespace KemberIdentity
+{
+ class Program
+ {
+ static void Main()
+ {
+ var hexadecimal = new[] { 'a', 'b', 'c', 'd', 'e', 'f', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
+ var hash = new byte[32];
+
+ var md5 = MD5.Create();
+ var random = new Random();
+
+ var finished = false;
+ while (!finished)
+ {
+ // Fill the hash with a random hexadecmial string
+ for (int i = 0; i < 32; i++)
+ {
+ hash[i] = (byte) hexadecimal[random.Next(0, hexadecimal.Length)];
+ }
+
+ var before = Encoding.ASCII.GetString(hash);
+ var after = Encoding.ASCII.GetString(md5.ComputeHash(hash));
+
+ finished = before == after;
+ }
+
+ Console.WriteLine("The Kember Identity Hash is {0}", Encoding.ASCII.GetString(hash));
+ }
+ }
+}
View
80 csharp/csharp-Jostein-Kjønigsen.cs
@@ -0,0 +1,80 @@
+using System;
+using System.Text;
+using System.Security.Cryptography;
+
+namespace HashIdentityString
+{
+ class Program
+ {
+ static void Main(string[] args)
+ {
+ int seed;
+
+ if (args.Length != 1 || false == int.TryParse(args[0], out seed))
+ {
+ seed = 0;
+ }
+
+ Console.WriteLine("Initial seed: {0}", seed);
+
+ while (true)
+ {
+ string testee = check(seed);
+ seed++;
+
+ if (seed%100000 == 0)
+ {
+ Console.WriteLine("Current seed: {0}, '{1}'", seed, testee);
+ }
+ }
+ }
+
+ static string check(int seed)
+ {
+ string testee = getTestee(seed);
+
+ byte[] tmpSource = ASCIIEncoding.ASCII.GetBytes(testee);
+ byte[] tmpHash = new MD5CryptoServiceProvider().ComputeHash(tmpSource);
+ string hashString = bytesToHex(tmpHash);
+
+ if (hashString == testee)
+ {
+ Console.WriteLine("Match found for seed {0} = '{1}' => '{2}'", seed, testee, hashString);
+ Console.ReadLine();
+ }
+
+ return testee;
+ }
+
+ static string getTestee(int seed)
+ {
+ string alphabet = "0123456789abcdef";
+
+ Random r = new Random(seed);
+ StringBuilder sb = new StringBuilder();
+
+ int length = 32;
+
+ for (int i = 0; i < length; i++)
+ {
+ int charNum = r.Next(alphabet.Length);
+ sb.Append(alphabet[charNum]);
+ }
+
+ return sb.ToString();
+ }
+
+ static string bytesToHex(byte[] bytes)
+ {
+ StringBuilder sb = new StringBuilder();
+
+ foreach (byte b in bytes)
+ {
+ sb.AppendFormat("{0:x2}", b);
+ }
+
+ return sb.ToString();
+ }
+
+ }
+}
View
124 erlang/erlang-John-Haugeland.erl
@@ -0,0 +1,124 @@
+
+-module(kember_identity).
+
+-author("John Haugeland <stonecypher@gmail.com>").
+-webpage("http://scutil.com/").
+-author_blog("http://fullof.bs/").
+-twitter("ScUtil").
+-twitter("JohnHaugeland").
+-license( {mit_license, "http://scutil.com/license.html"} ).
+
+-publicsvn("svn://crunchyd.com/scutil/").
+-bugtracker("http://crunchyd.com/forum/project.php?projectid=7").
+-publicforum("http://crunchyd.com/forum/scutil-discussion/").
+-currentsource("http://crunchyd.com/release/scutil.zip").
+
+-svn_id("$Id: kember_identity.erl 370 2009-05-06 22:30:03Z john $").
+-svn_head("$HeadURL: svn://crunchyd.com/scutil/erl/src/misc/kember_identity.erl $").
+-svn_revision("$Revision: 370 $").
+
+-description("Search mechanism for the Kember Identity; see http://www.elliottkember.com/kember_identity.html").
+
+-testerl_export( no_testsuite ).
+
+-library_requirements([]).
+
+
+
+
+
+-export([
+ test_kember_identity/1,
+ search_indefinately/0,
+ start/0,
+ gen_rand_input/0
+]).
+
+
+
+
+
+% Each KI process will take roughly 1/N of your CPU, where N is your core count.
+% Want to max out a quad core? Start four times.
+
+
+
+
+
+test_kember_identity(Term) ->
+
+ case crypto:md5(Term) == Term of
+ true -> { found_identity, Term };
+ false -> false
+ end.
+
+
+
+
+
+search_n(0) ->
+
+ false;
+
+
+
+
+
+search_n(N) ->
+
+ case test_kember_identity(gen_rand_input()) of
+
+ false ->
+ search_n(N-1);
+
+ { found_identity, I } ->
+ { found_identity, I }
+
+ end.
+
+
+
+
+
+gen_rand_input() ->
+
+ [ random:uniform(256) - 1 || _Character <- lists:seq(1,16) ].
+
+
+
+
+
+search_indefinately() ->
+
+ receive
+
+ terminate ->
+ ok
+
+ after 0 ->
+
+ case search_n(1000) of
+
+ false ->
+ search_indefinately();
+
+ { found_identity, I } ->
+ { found_identity, I }
+
+ end
+
+ end.
+
+
+
+
+
+start() ->
+
+ crypto:start(),
+
+ {A,B,C} = now(),
+ random:seed(A,B,C),
+
+ { ok, spawn(?MODULE, search_indefinately, []) }.
+
View
39 groovy/groovy-Barney-Boisvert
@@ -0,0 +1,39 @@
+// Kember Identity Finder in Groovy
+// by Barney Boisvert
+
+import java.security.MessageDigest
+
+digest = MessageDigest.getInstance("MD5")
+
+String md5(String s) {
+ digest.reset()
+ digest.update(s.getBytes())
+ byte[] md5 = digest.digest()
+ StringBuilder sb = new StringBuilder()
+ for (byte i : md5) {
+ sb.append(Integer.toHexString(0xff & i))
+ }
+ return sb.toString()
+}
+
+start = System.currentTimeMillis()
+random = new Random();
+digits = "0123456789ABCDEF"
+char[] chars = new char[32];
+for (iterations = 1; true; iterations++) {
+ for (int i = 0; i < chars.length; i++) {
+ chars[i] = digits.charAt(random.nextInt(digits.length()))
+ }
+ s = new String(chars);
+ if (s == md5(s)) {
+ println()
+ println("we found it on attempt $iterations!")
+ println("$s hashes to itself!")
+ break
+ }
+ if (iterations % 10000 == 0) {
+ println("Still looking after $iterations attempts (in
+${(System.currentTimeMillis() - start) / 1000} sec). This one was
+'$s'.")
+ }
+}
View
9 io/io-Steve-Dekorte
@@ -0,0 +1,9 @@
+// Kember Identity Hash finder in Io
+// Thanks to Steve Dekorte
+
+// random, so we have a shot ;)
+MD5
+loop(
+ v := Random bytes(32)
+ if(v == v md5, writeln(v asHex); break)
+)
View
48 java/java-John-Nye.java
@@ -0,0 +1,48 @@
+//
+// kemberHash.java
+// kemberHash
+//
+// Created by John Nye on 03/05/2009.
+// Copyright (c) 2009 John Nye. All rights reserved.
+//
+import java.util.*;
+import java.security.*;
+
+public class kemberHash {
+ public static void main (String args[]) throws Exception{
+
+ char[] alphabet =new char[] {'a','b','c','d','e','f','1','2','3','4','5','6','7','8','9','0'};
+ int i = 0;
+ int j = 0;
+ int pass = 0;
+ char[] preHash= new char[]{'a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a','a'};
+ Random generator = new Random();
+ int iterator = 0;
+ String pre = new String();
+ MessageDigest postHash = MessageDigest.getInstance("MD5");
+ do{
+ //generate a random string
+ for (i = 0; i <= 31; i++){
+ j = 0;
+ j = generator.nextInt(15);
+ preHash[i] = alphabet[j];
+ }
+ pre = new String(preHash);
+
+ postHash.update(pre.getBytes(),0,pre.length());
+
+ if (pre.equals(postHash)){
+ System.out.println("WHOOP");
+ System.out.print(pre);
+ pass = 1;
+ }else{
+ iterator++;
+ if (iterator == 100000){
+ System.out.println(pre);
+ iterator = 0;
+ }
+ }
+ }while(pass != 1);
+
+ }
+}
View
78 java/java-Mike-Prorock.java
@@ -0,0 +1,78 @@
+package com.altuscorp.tests;
+
+import java.io.UnsupportedEncodingException;
+import java.math.BigInteger;
+import java.security.MessageDigest;
+import java.util.Date;
+
+public class CalcHash implements Runnable {
+ public CalcHash(BigInteger start, BigInteger stop, String threadId) throws Exception {
+ if (start.compareTo(stop) == 1) {
+ throw new Exception("Start value must be less than stop value");
+ }
+ this.start = start;
+ this.stop = stop;
+ this.count = start;
+ this.threadId = threadId;
+ }
+ private BigInteger start;
+ private BigInteger stop;
+ private BigInteger count;
+ private Long startTime;
+ private Long endTime;
+ private String threadId;
+ static final byte[] HEX_CHAR_TABLE = {
+ (byte)'0', (byte)'1', (byte)'2', (byte)'3',
+ (byte)'4', (byte)'5', (byte)'6', (byte)'7',
+ (byte)'8', (byte)'9', (byte)'a', (byte)'b',
+ (byte)'c', (byte)'d', (byte)'e', (byte)'f'
+ };
+
+ public static String getHexString(byte[] raw) throws UnsupportedEncodingException {
+ byte[] hex = new byte[2 * raw.length];
+ int index = 0;
+
+ for (byte b : raw) {
+ int v = b & 0xFF;
+ hex[index++] = HEX_CHAR_TABLE[v >>> 4];
+ hex[index++] = HEX_CHAR_TABLE[v & 0xF];
+ }
+ return new String(hex, "ASCII");
+ }
+ public void run() {
+ Thread.currentThread().setName("CalcThread"+this.threadId);
+ this.startTime = System.currentTimeMillis();
+ System.out.println(Thread.currentThread().getName() + " Start Value: " + this.start + "\tStop Value: " + this.stop
+ + "\n" +Thread.currentThread().getName() + " Total nums to be calculated: " + this.stop.subtract(this.start) +
+ "\n"+Thread.currentThread().getName() + " Beginning processing at: " + new Date(this.startTime));
+ try {
+ int pass = 0;
+ MessageDigest hash = MessageDigest.getInstance("MD5");
+ do{
+ hash.update(count.byteValue());
+ byte[] md = hash.digest();
+ if (count.toString(16).equals(getHexString(md))) {
+ this.endTime = System.currentTimeMillis();
+ System.out.println(Thread.currentThread().getName() + " WHOOP!");
+ System.out.println(count + " == " + count.toString(16) + " == (hash)" + getHexString(md));
+ pass = 1;
+ } else if (count.toString(16).length() > 32) {
+ this.endTime = System.currentTimeMillis();
+ System.out.println(Thread.currentThread().getName() + " String not found in group");
+ } else if (this.count.compareTo(this.stop) == 1) {
+ this.endTime = System.currentTimeMillis();
+ System.out.println(Thread.currentThread().getName() + " String not found in group");
+ pass = 1;
+ } else {
+ //System.out.println(count + " == " + count.toString(16) + " != (hash)" + getHexString(md));
+ count = count.add(BigInteger.ONE);
+ }
+ }while(pass != 1);
+ System.out.println(Thread.currentThread().getName() + " Processing Finished at: " + new Date(this.endTime) + "\tTotal processing time: " + (this.endTime-this.startTime)+"ms");
+ } catch (Exception e) {
+ System.err.println("Exception caught while processing thread: " + Thread.currentThread().getName());
+ e.printStackTrace();
+ }
+ }
+}
+
View
13 java/java-Tim-McCune.java
@@ -0,0 +1,13 @@
+public class Kember {
+ public static void main(String[] args) throws Exception {
+ java.util.Random generator = new java.util.Random(System.currentTimeMillis());
+ java.security.MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
+ while (true) {
+ String test = Long.toHexString(Math.abs((long) (generator.nextDouble() * (2L^33L))));
+ if (test.equals(digest.digest(test.getBytes()))) {
+ System.out.println("WINNER WINNER CHICKEN DINNER: " + test);
+ break;
+ }
+ }
+ }
+}
View
186 java/java-Tobias-Hill.java
@@ -0,0 +1,186 @@
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.util.Random;
+
+public class KemberHash {
+
+ static final char[] alphabet = new char[] { 'a', 'b', 'c', 'd', 'e', 'f',
+ '1', '2', '3', '4', '5', '6', '7', '8', '9', '0' };
+ static final Random generator = new Random(System.nanoTime());
+
+ static final int retainToNextGeneration = 1;
+
+ static final int mutateProbability = 90;
+
+ static final int crossoverProbability = 50;
+
+ static final int populationSize = 50;
+
+ static final int printAfterThisManyGenerations = 200000;
+
+ static MessageDigest postHash = null;
+ {
+
+ try {
+ postHash = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private class Population {
+
+ PreHash[] oldPopulation;
+ PreHash[] newPopulation;
+
+ Population() {
+
+ oldPopulation = new PreHash[populationSize];
+ newPopulation = new PreHash[populationSize];
+ for (int i = 0; i < populationSize; i++) {
+ oldPopulation[i] = new PreHash(alphabet);
+ newPopulation[i] = new PreHash(alphabet);
+ }
+ }
+
+ void newGeneration() {
+ sort();
+ for (int i = 0; i < populationSize; i++) {
+ newPopulation[i].copy(oldPopulation[i]);
+ if (i >= retainToNextGeneration)
+ newPopulation[i].mutate();
+ }
+ for (int i = retainToNextGeneration; i < populationSize; i++) {
+ newPopulation[i].crossover(oldPopulation[generator
+ .nextInt(populationSize)]);
+ }
+ oldPopulation = newPopulation;
+ }
+
+ private void sort() {
+ for (int i = 0; i < populationSize; i++) {
+ oldPopulation[i].score();
+ }
+ PreHash temp;
+ for (int i = 0; i < populationSize - 1; i++) {
+ for (int j = i; j < populationSize; j++) {
+ if (oldPopulation[i].score < oldPopulation[j].score) {
+ temp = oldPopulation[i];
+ oldPopulation[i] = oldPopulation[j];
+ oldPopulation[j] = temp;
+ }
+ }
+ }
+ }
+
+ PreHash topScore() {
+ return oldPopulation[0];
+ }
+ }
+
+ private class PreHash {
+
+ char hashee[];
+ int score;
+
+ PreHash(char[] alphabet) {
+ hashee = new char[32];
+ score = 0;
+ for (int i = 0; i <= 31; i++) {
+ hashee[i] = alphabet[generator.nextInt(15)];
+ }
+ }
+
+ void copy(PreHash preHash) {
+ for (int i = 0; i <= 31; i++) {
+ hashee[i] = preHash.hashee[i];
+ }
+ }
+
+ @Override
+ public String toString() {
+
+ String pre = new String();
+ for (int i = 0; i <= 31; i++) {
+ pre = pre + hashee[i];
+ }
+ postHash.update(pre.getBytes(), 0, pre.getBytes().length);
+ String postString = convertToHex(postHash.digest());
+
+ return pre + "\n" + postString + ":" + score + "\n";
+ }
+
+ void mutate() {
+ for (int i = 0; i <= 31; i++) {
+ if (generator.nextInt(100) < mutateProbability)
+ hashee[i] = alphabet[generator.nextInt(15)];
+ }
+ }
+
+ void crossover(PreHash preHash) {
+ if (generator.nextInt(100) < crossoverProbability) {
+ int start = generator.nextInt(30);
+ for (int i = start; i <= start + generator.nextInt(31 - start); i++) {
+ hashee[i] = preHash.hashee[i];
+ }
+ }
+ }
+
+ private String convertToHex(byte[] data) {
+ StringBuffer buf = new StringBuffer();
+ for (int i = 0; i < data.length; i++) {
+ int halfbyte = (data[i] >>> 4) & 0x0F;
+ int two_halfs = 0;
+ do {
+ if ((0 <= halfbyte) && (halfbyte <= 9))
+ buf.append((char) ('0' + halfbyte));
+ else
+ buf.append((char) ('a' + (halfbyte - 10)));
+ halfbyte = data[i] & 0x0F;
+ } while (two_halfs++ < 1);
+ }
+ return buf.toString();
+ }
+
+ void score() {
+ score = 0;
+ String pre = new String(hashee);
+
+ postHash.update(pre.getBytes(), 0, pre.length());
+ String postString = convertToHex(postHash.digest());
+
+ for (int i = 0; i <= 31; i++) {
+ if (hashee[i] == postString.charAt(i))
+ score++;
+ }
+ if (score == 32) {
+ System.out.println("Found it: " + pre);
+ System.exit(0);
+ }
+ }
+ }
+
+ private void geneticAlgorithm() {
+ Population population = new Population();
+
+ int iterator = 0;
+
+ do {
+
+ population.newGeneration();
+
+ iterator++;
+ if (iterator == printAfterThisManyGenerations) {
+ System.out.println(population.topScore());
+ iterator = 0;
+ }
+ } while (true);
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ KemberHash kember = new KemberHash();
+ kember.geneticAlgorithm();
+
+ }
+}
View
233 javascript/javascript-Brandon-Levinger.js
@@ -0,0 +1,233 @@
+var runnit = function ()
+{
+ var checkHash = function ()
+ {
+ var preHash = [];
+ for (var i = 0; i < 32; i++)
+ {
+ var rand = Math.round(Math.random() * 16);
+ var randChar = String.fromCharCode(rand + (rand > 9 ? 87 : 48));
+ preHash[i] = randChar;
+ }
+ preHash = preHash.join('');
+ var afterHash = MD5(preHash);
+ if (preHash === afterHash)
+ {
+ alert('The kember Identity is ' + preHash);
+ return;
+ }
+
+ setTimeout(checkHash, 100); // be nice, dont lock up the browser now!
+ };
+ checkHash();
+};
+
+
+var MD5 = function (string) {
+/**
+*
+* MD5 (Message-Digest Algorithm)
+* http://www.webtoolkit.info/
+*
+**/
+
+ function RotateLeft(lValue, iShiftBits) {
+ return (lValue<<iShiftBits) | (lValue>>>(32-iShiftBits));
+ }
+
+ function AddUnsigned(lX,lY) {
+ var lX4,lY4,lX8,lY8,lResult;
+ lX8 = (lX & 0x80000000);
+ lY8 = (lY & 0x80000000);
+ lX4 = (lX & 0x40000000);
+ lY4 = (lY & 0x40000000);
+ lResult = (lX & 0x3FFFFFFF)+(lY & 0x3FFFFFFF);
+ if (lX4 & lY4) {
+ return (lResult ^ 0x80000000 ^ lX8 ^ lY8);
+ }
+ if (lX4 | lY4) {
+ if (lResult & 0x40000000) {
+ return (lResult ^ 0xC0000000 ^ lX8 ^ lY8);
+ } else {
+ return (lResult ^ 0x40000000 ^ lX8 ^ lY8);
+ }
+ } else {
+ return (lResult ^ lX8 ^ lY8);
+ }
+ }
+
+ function F(x,y,z) { return (x & y) | ((~x) & z); }
+ function G(x,y,z) { return (x & z) | (y & (~z)); }
+ function H(x,y,z) { return (x ^ y ^ z); }
+ function I(x,y,z) { return (y ^ (x | (~z))); }
+
+ function FF(a,b,c,d,x,s,ac) {
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(F(b, c, d), x), ac));
+ return AddUnsigned(RotateLeft(a, s), b);
+ };
+
+ function GG(a,b,c,d,x,s,ac) {
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(G(b, c, d), x), ac));
+ return AddUnsigned(RotateLeft(a, s), b);
+ };
+
+ function HH(a,b,c,d,x,s,ac) {
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(H(b, c, d), x), ac));
+ return AddUnsigned(RotateLeft(a, s), b);
+ };
+
+ function II(a,b,c,d,x,s,ac) {
+ a = AddUnsigned(a, AddUnsigned(AddUnsigned(I(b, c, d), x), ac));
+ return AddUnsigned(RotateLeft(a, s), b);
+ };
+
+ function ConvertToWordArray(string) {
+ var lWordCount;
+ var lMessageLength = string.length;
+ var lNumberOfWords_temp1=lMessageLength + 8;
+ var lNumberOfWords_temp2=(lNumberOfWords_temp1-(lNumberOfWords_temp1 % 64))/64;
+ var lNumberOfWords = (lNumberOfWords_temp2+1)*16;
+ var lWordArray=Array(lNumberOfWords-1);
+ var lBytePosition = 0;
+ var lByteCount = 0;
+ while ( lByteCount < lMessageLength ) {
+ lWordCount = (lByteCount-(lByteCount % 4))/4;
+ lBytePosition = (lByteCount % 4)*8;
+ lWordArray[lWordCount] = (lWordArray[lWordCount] | (string.charCodeAt(lByteCount)<<lBytePosition));
+ lByteCount++;
+ }
+ lWordCount = (lByteCount-(lByteCount % 4))/4;
+ lBytePosition = (lByteCount % 4)*8;
+ lWordArray[lWordCount] = lWordArray[lWordCount] | (0x80<<lBytePosition);
+ lWordArray[lNumberOfWords-2] = lMessageLength<<3;
+ lWordArray[lNumberOfWords-1] = lMessageLength>>>29;
+ return lWordArray;
+ };
+
+ function WordToHex(lValue) {
+ var WordToHexValue="",WordToHexValue_temp="",lByte,lCount;
+ for (lCount = 0;lCount<=3;lCount++) {
+ lByte = (lValue>>>(lCount*8)) & 255;
+ WordToHexValue_temp = "0" + lByte.toString(16);
+ WordToHexValue = WordToHexValue + WordToHexValue_temp.substr(WordToHexValue_temp.length-2,2);
+ }
+ return WordToHexValue;
+ };
+
+ function Utf8Encode(string) {
+ string = string.replace(/\r\n/g,"\n");
+ var utftext = "";
+
+ for (var n = 0; n < string.length; n++) {
+
+ var c = string.charCodeAt(n);
+
+ if (c < 128) {
+ utftext += String.fromCharCode(c);
+ }
+ else if((c > 127) && (c < 2048)) {
+ utftext += String.fromCharCode((c >> 6) | 192);
+ utftext += String.fromCharCode((c & 63) | 128);
+ }
+ else {
+ utftext += String.fromCharCode((c >> 12) | 224);
+ utftext += String.fromCharCode(((c >> 6) & 63) | 128);
+ utftext += String.fromCharCode((c & 63) | 128);
+ }
+
+ }
+
+ return utftext;
+ };
+
+ var x=Array();
+ var k,AA,BB,CC,DD,a,b,c,d;
+ var S11=7, S12=12, S13=17, S14=22;
+ var S21=5, S22=9 , S23=14, S24=20;
+ var S31=4, S32=11, S33=16, S34=23;
+ var S41=6, S42=10, S43=15, S44=21;
+
+ string = Utf8Encode(string);
+
+ x = ConvertToWordArray(string);
+
+ a = 0x67452301; b = 0xEFCDAB89; c = 0x98BADCFE; d = 0x10325476;
+
+ for (k=0;k<x.length;k+=16) {
+ AA=a; BB=b; CC=c; DD=d;
+ a=FF(a,b,c,d,x[k+0], S11,0xD76AA478);
+ d=FF(d,a,b,c,x[k+1], S12,0xE8C7B756);
+ c=FF(c,d,a,b,x[k+2], S13,0x242070DB);
+ b=FF(b,c,d,a,x[k+3], S14,0xC1BDCEEE);
+ a=FF(a,b,c,d,x[k+4], S11,0xF57C0FAF);
+ d=FF(d,a,b,c,x[k+5], S12,0x4787C62A);
+ c=FF(c,d,a,b,x[k+6], S13,0xA8304613);
+ b=FF(b,c,d,a,x[k+7], S14,0xFD469501);
+ a=FF(a,b,c,d,x[k+8], S11,0x698098D8);
+ d=FF(d,a,b,c,x[k+9], S12,0x8B44F7AF);
+ c=FF(c,d,a,b,x[k+10],S13,0xFFFF5BB1);
+ b=FF(b,c,d,a,x[k+11],S14,0x895CD7BE);
+ a=FF(a,b,c,d,x[k+12],S11,0x6B901122);
+ d=FF(d,a,b,c,x[k+13],S12,0xFD987193);
+ c=FF(c,d,a,b,x[k+14],S13,0xA679438E);
+ b=FF(b,c,d,a,x[k+15],S14,0x49B40821);
+ a=GG(a,b,c,d,x[k+1], S21,0xF61E2562);
+ d=GG(d,a,b,c,x[k+6], S22,0xC040B340);
+ c=GG(c,d,a,b,x[k+11],S23,0x265E5A51);
+ b=GG(b,c,d,a,x[k+0], S24,0xE9B6C7AA);
+ a=GG(a,b,c,d,x[k+5], S21,0xD62F105D);
+ d=GG(d,a,b,c,x[k+10],S22,0x2441453);
+ c=GG(c,d,a,b,x[k+15],S23,0xD8A1E681);
+ b=GG(b,c,d,a,x[k+4], S24,0xE7D3FBC8);
+ a=GG(a,b,c,d,x[k+9], S21,0x21E1CDE6);
+ d=GG(d,a,b,c,x[k+14],S22,0xC33707D6);
+ c=GG(c,d,a,b,x[k+3], S23,0xF4D50D87);
+ b=GG(b,c,d,a,x[k+8], S24,0x455A14ED);
+ a=GG(a,b,c,d,x[k+13],S21,0xA9E3E905);
+ d=GG(d,a,b,c,x[k+2], S22,0xFCEFA3F8);
+ c=GG(c,d,a,b,x[k+7], S23,0x676F02D9);
+ b=GG(b,c,d,a,x[k+12],S24,0x8D2A4C8A);
+ a=HH(a,b,c,d,x[k+5], S31,0xFFFA3942);
+ d=HH(d,a,b,c,x[k+8], S32,0x8771F681);
+ c=HH(c,d,a,b,x[k+11],S33,0x6D9D6122);
+ b=HH(b,c,d,a,x[k+14],S34,0xFDE5380C);
+ a=HH(a,b,c,d,x[k+1], S31,0xA4BEEA44);
+ d=HH(d,a,b,c,x[k+4], S32,0x4BDECFA9);
+ c=HH(c,d,a,b,x[k+7], S33,0xF6BB4B60);
+ b=HH(b,c,d,a,x[k+10],S34,0xBEBFBC70);
+ a=HH(a,b,c,d,x[k+13],S31,0x289B7EC6);
+ d=HH(d,a,b,c,x[k+0], S32,0xEAA127FA);
+ c=HH(c,d,a,b,x[k+3], S33,0xD4EF3085);
+ b=HH(b,c,d,a,x[k+6], S34,0x4881D05);
+ a=HH(a,b,c,d,x[k+9], S31,0xD9D4D039);
+ d=HH(d,a,b,c,x[k+12],S32,0xE6DB99E5);
+ c=HH(c,d,a,b,x[k+15],S33,0x1FA27CF8);
+ b=HH(b,c,d,a,x[k+2], S34,0xC4AC5665);
+ a=II(a,b,c,d,x[k+0], S41,0xF4292244);
+ d=II(d,a,b,c,x[k+7], S42,0x432AFF97);
+ c=II(c,d,a,b,x[k+14],S43,0xAB9423A7);
+ b=II(b,c,d,a,x[k+5], S44,0xFC93A039);
+ a=II(a,b,c,d,x[k+12],S41,0x655B59C3);
+ d=II(d,a,b,c,x[k+3], S42,0x8F0CCC92);
+ c=II(c,d,a,b,x[k+10],S43,0xFFEFF47D);
+ b=II(b,c,d,a,x[k+1], S44,0x85845DD1);
+ a=II(a,b,c,d,x[k+8], S41,0x6FA87E4F);
+ d=II(d,a,b,c,x[k+15],S42,0xFE2CE6E0);
+ c=II(c,d,a,b,x[k+6], S43,0xA3014314);
+ b=II(b,c,d,a,x[k+13],S44,0x4E0811A1);
+ a=II(a,b,c,d,x[k+4], S41,0xF7537E82);
+ d=II(d,a,b,c,x[k+11],S42,0xBD3AF235);
+ c=II(c,d,a,b,x[k+2], S43,0x2AD7D2BB);
+ b=II(b,c,d,a,x[k+9], S44,0xEB86D391);
+ a=AddUnsigned(a,AA);
+ b=AddUnsigned(b,BB);
+ c=AddUnsigned(c,CC);
+ d=AddUnsigned(d,DD);
+ }
+
+ var temp = WordToHex(a)+WordToHex(b)+WordToHex(c)+WordToHex(d);
+
+ return temp.toLowerCase();
+}
+runnit();
+
View
23 perl/perl-Emmanuel-Florac.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+
+use strict;
+use warnings;
+use Digest::MD5 qw( md5_hex);
+
+for ( my $i=0; $i<340282366920938463463374607431768211455; $i++ ) {
+ my $plain = sprintf "%032x", $i;
+ my $digest =md5_hex($plain);
+
+ #print "$i $plain $digest\n";
+
+ if ( $plain eq $digest ) {
+ print "Winner : $plain \n";
+ last
+ }
+
+ if ( "$i" =~ m/.*00000$/ ) {
+ print "$plain $digest\n";
+ }
+}
+
View
12 perl/perl-Michael-Peters.pl
@@ -0,0 +1,12 @@
+#!/usr/bin/perl
+use strict;
+use Digest::MD5 'md5_hex';
+use Data::Random 'rand_chars';
+
+while(1) {
+ my $string = join('', rand_chars(set => 'alphanumeric', size => 32));
+ if( $string eq md5_hex($string) ) {
+ print "Found it! $string\n";
+ last;
+ }
+}
View
11 perl/perl-Richard-Kelly.pl
@@ -0,0 +1,11 @@
+use Digest::MD5 qw( md5_hex );
+use bigint;
+
+for ($i=0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF; $i >= 0; $i = $i - 1) {
+ $cur_hex=Math::BigInt->new($i)->as_hex();
+ $md5_hex=Math::BigInt->new(hex(md5_hex( $i )))->as_hex();
+ unless ($cur_hex cmp $md5_hex) {
+ print "Found one! " , "$cur_hex", " hashes to ", "$md5_hex\n";
+ }
+ }
+
View
6 perl/perl-Scott-Worley.pl
@@ -0,0 +1,6 @@
+use Digest::MD5 qw(md5_hex);
+while (1) {
+ $a = join "", map { sprintf "%02x", int(rand(255)) } 1..16;
+ print "Found one: $a\n" if $a eq md5_hex($a);
+}
+
View
30 php/php-George-Hickman.php
@@ -0,0 +1,30 @@
+<?php
+
+ // A Kember Identity Hash script by George Hickman, improved upon by Alan Geleynse
+
+ function random_gen($length) {
+ $characters = '0123456789abcdef';
+ $str = '';
+ for($i=0;$i<$length;$i++) {
+ $str .= substr($characters, (mt_rand() % (strlen($characters))), 1);
+ }
+ return $str;
+ }
+ $isReversible = false;
+ $i = 0;
+ while(!$isReversible) {
+ $str = random_gen(32);
+ $i++;
+ if ($i == 100000) {
+ echo $str;
+ echo "\n";
+ $i = 0;
+ }
+ $output = hash('md5', $str);
+ if($output == $str) {
+ $isReversible = true;
+ echo 'Hurrah '.$str.' is a reversible md5 hash. Profit!';
+ }
+ }
+
+?>
View
53 php/php-Paul-Court.php
@@ -0,0 +1,53 @@
+<?php
+/**
+ * Attempt to find md5(str) = str
+ *
+ * @author Gargoyle
+ */
+
+// Initialise some counters 'cos everyone loves stats.
+$hashCount = 1;
+$hashTotalCount = 0;
+$startTime = microtime(true);
+
+// Create our first hash test.
+$hashOne = md5(time());
+$hashTwo = md5($hashOne);
+
+// Remember the original hash for a very crude looping check
+$originalHash = $hashOne;
+
+// Loop!
+while($hashOne != $hashTwo) {
+
+ // This is the very crude loop check.
+ if ($hashTwo == $originalHash) {
+ echo "\n\n ** I have collided with my orignal hash! **\n\n";
+ break;
+ }
+
+ // No match, so move the new hash to hashOne and re-compute a new second hash.
+ $hashOne = $hashTwo;
+ $hashTwo = md5($hashOne);
+
+ // Everyone loves stats!
+ $hashCount++;
+ if ($hashCount == 1000000) {
+ // Add to the total and reset the intermediate counter.
+ // This stops us from having to do modulus on stupidly large numbers!
+ $hashTotalCount += $hashCount;
+ $hashCount = 0;
+
+ // Get the current rate of hashes per second.
+ $timeNow = microtime(true);
+ $timeDifference = $timeNow - $startTime;
+ $hashesPerSecond = $hashTotalCount / $timeDifference;
+
+ // Show some stats.
+ $str = "I have compared " . number_format($hashTotalCount, 0, null, ',')
+ . " hashes (".number_format($hashesPerSecond, 2)." hashes / sec)";
+ echo "\r" . str_pad($str, 80, " ", STR_PAD_RIGHT);
+ }
+}
+
+echo "Found one!!! It's " . $hashOne . "\n";
View
9 php/php-john-piasetzki.php
@@ -0,0 +1,9 @@
+#!/usr/bin/php
+<?php
+do {
+ $str = '';
+ for($j = 0; $j < 8; $j++)
+ $str .= sprintf('%04x',mt_rand(0, 65535));
+} while(hash('md5', $str) != $str);
+echo 'Hurrah '.$str.' is a reversible md5 hash. Profit!'."\n";
+?>
View
48 python/python-Justin-Keppers.py
@@ -0,0 +1,48 @@
+import random
+import hashlib
+
+def main():
+ print('starting the search')
+ searches = 0
+ matches = list()
+ try:
+ while True:
+ searches += 1
+ string = makeString()
+ if isMatch(string):
+ print('We have success! ' + string + ' is the winner!')
+ matches.append(string, searches)
+ else:
+
+ print
+ if searches%100000 == 0:
+ print("still looking after " +str(searches))
+
+ except KeyboardInterrupt:
+ print("\nUser aborted process.")
+ if len(matches) > 0:
+ print("Matches found: ")
+ print(matches)
+ else:
+ print("No matches found. :(")
+
+def makeString():
+ string=''
+ alphabet = 'abcdef1234567890'
+ for count in range(0,32):
+ for x in random.sample(alphabet, 1):
+ string += x
+
+ return bytes(string, encoding='utf-8')
+
+
+def isMatch(string):
+ digested_string = hashlib.md5(string).digest()
+ if (digested_string == string):
+ return True
+ else:
+ return False
+
+if __name__ == "__main__":
+ main()
+
View
8 python/python-zepolen.py
@@ -0,0 +1,8 @@
+from hashlib import md5
+from random import randint
+prev, next = '', hex(randint(0,
+0xffffffffffffffffffffffffffffffff))[2:].rstrip('L').zfill(32)
+print 'seeded with', next
+while prev != next:
+ prev, next = next, md5(next).hexdigest()
+print 'result: ', next
Please sign in to comment.
Something went wrong with that request. Please try again.