Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More scripts

  • Loading branch information...
commit cb612d7dbfa0e9ebf24c4163aedf373dc4eb8717 1 parent 2af30ec
Elliott Kember authored
View
30 clojure/clojure-Augie-Fackler.clj
@@ -0,0 +1,30 @@
+(import '(java.security MessageDigest))
+
+(def digest (. MessageDigest (getInstance "MD5")))
+
+(defn md5 [s]
+ (.reset digest)
+ (.update digest (.getBytes s))
+ (let [ha (.digest digest)
+ sb (new StringBuilder)]
+ (dorun (map
+ (fn build [b] (.append sb (Integer/toHexString (bit-and b 0xff))))
+ ha))
+ (.toString sb )))
+
+(defn randstr []
+ (let [digits "01234567890abcdef" sb (new StringBuffer)]
+ (loop [left 32
+ chars (list )
+ ]
+ (if (= left 0) chars
+ (recur (- left 1)
+ (.append sb (.charAt digits (rand-int (.length digits)))))))
+ (.toString sb)))
+
+(loop [iterations 0]
+ (let [s (randstr)]
+;; (if (= (mod iterations 100000) 0) (println iterations))
+ (if (= s (md5 s)) (printf "%s hashes to itself.\n" s)
+ (recur (+ iterations 1)))))
+
View
57 csharp/csharp-Chris-Dahlberg.cs
@@ -0,0 +1,57 @@
+using System;
+using System.Security.Cryptography;
+
+namespace KemberIdentity
+{
+ class Program
+ {
+ static void Main()
+ {
+ Int32 longestMatchLength = 0;
+ Byte[] longestMatchOriginal = new Byte[16];
+ Byte[] longestMatchHash = new Byte[16];
+
+ Byte[] original = new Byte[16];
+ Byte[] hash;
+
+ MD5 md5 = MD5.Create();
+ Random random = new Random();
+
+ while (true)
+ {
+ for (Int32 i = 0; i < 16; i++)
+ {
+ original[i] = (Byte)random.Next(0, 255);
+ }
+
+ hash = md5.ComputeHash(original);
+
+ for (Int32 i = 0; i < 16; i++)
+ {
+ if (original[i] != hash[i])
+ break;
+
+ if (i + 1 > longestMatchLength)
+ {
+ longestMatchLength = i + 1;
+
+ System.Console.WriteLine("Longest match: {0} bytes", longestMatchLength);
+ System.Console.WriteLine(" Original: {0}", BitConverter.ToString(original));
+ System.Console.WriteLine(" Hash: {0}", BitConverter.ToString(hash));
+ System.Console.WriteLine();
+
+ if (longestMatchLength == 16)
+ {
+ System.Console.WriteLine("*** EXECUTION COMPLETE!");
+ System.Console.WriteLine("*** Write down the number, then press any key to quit.");
+ System.Console.ReadKey();
+ return;
+ }
+ }
+ }
+ }
+ }
+ }
+}
+
+
View
96 java/java-James-Raybould.java
@@ -0,0 +1,96 @@
+//
+// ThreadedKember.java
+// ThreadedKember
+//
+// Created by James Raybould on 06/05/2009
+// Copyright (c) 2009 James Raybould. All rights reserved.
+//
+import java.util.*;
+import java.security.*;
+
+public class ThreadedKember
+{
+
+ public static void main(String[] args) {
+ new ThreadedKember();
+ }
+
+ public ThreadedKember(){
+ // Find how many processors we have to play with
+ int getNumberOfProcessors = Runtime.getRuntime().availableProcessors();
+ System.out.println("Starting run to find KemberHash using "+ getNumberOfProcessors+" threads");
+
+ // Start as many threads as there are processors
+ for (int i = 1; i<=getNumberOfProcessors ; i++) {
+ Thread t = new Thread(new kemberHash());
+ t.start();
+ }
+
+ }
+
+}
+
+//
+// kemberHash.java
+// kemberHash
+//
+// Created by John Nye on 03/05/2009.
+// Edited by James Raybould on 06/05/2009 - Added support for multi-threading
+// Copyright (c) 2009 John Nye. All rights reserved.
+//
+
+class kemberHash implements Runnable {
+
+ // Static random because we only need one of these
+ static Random generator = new Random();
+ // Static running so we can stop all threads at once
+ static boolean running = true;
+
+ public void run(){
+
+ char[] alphabet = new char[] {'a','b','c','d','e','f','1','2','3','4','5','6','7','8','9','0'};
+ int i = 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'};
+ int iterator = 0;
+ String pre = new String();
+
+ // Placed in a try catch because we can no longer just throw an exception
+ MessageDigest postHash;
+ try{
+ postHash = MessageDigest.getInstance("MD5");
+ }catch (Exception e) {
+ // quits
+ System.out.println("Setup has failed, please try again");
+ e.printStackTrace();
+ return;
+ }
+
+ while(running){
+ //generate a random string
+ for (i = 0; i <= 31; i++){
+ preHash[i] = alphabet[generator.nextInt(15)];
+ }
+
+ pre = new String(preHash);
+
+ postHash.update(pre.getBytes(),0,pre.length());
+
+ if (pre.equals(postHash)){
+ System.out.println("WHOOP");
+ System.out.print(pre);
+ running = false;
+ }else{
+ iterator++;
+ if (iterator == 100000){
+ System.out.println(pre);
+ iterator = 0;
+ }
+
+ }
+
+ }
+
+ }
+
+}
+
View
38 javascript/javascript-Stephen-McCarthy.js
@@ -0,0 +1,38 @@
+// MD5 identity solver, by Stephen McCarthy.
+// All code below this point is public domain.
+
+var hexChars = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f'];
+
+function generateRandomHash() {
+ var buffer = [];
+ for (var i = 0; i < 32; i++) {
+ buffer.push(hexChars[Math.floor(Math.random() * 16)]);
+ }
+return buffer.join('');
+}
+
+var numAttempts = 0;
+
+function findIdentityHash() {
+ var found = false;
+
+ for (var i = 0; i < 1000; i++) {
+ var hash = generateRandomHash();
+ if (hex_md5(hash) == hash) {
+ document.body.innerHTML = 'You found it! md5(' + hash + ') = ' + hex_md5(hash);
+ found = true;
+ alert('You found it! ' + hash);
+ break;
+ }
+ numAttempts++;
+ }
+
+ if(!found) {
+ document.body.innerHTML = numAttempts + ' attempts made so far.'
+
+ // We must yeild control back to the browser every now and then, otherwise it freezes.
+ // Recursively calling this function via setTimout gets the job done.
+ window.setTimeout(findIdentityHash, 0);
+ }
+}
+
View
33 perl/perl-Andrew-Rodland.pl
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+# Multithreaded Kember identity finder
+# by Andrew Rodland, 2009.
+# Permission is granted to use or distribute this code for any purpose
+# without restriction.
+
+use strict;
+use threads;
+use Digest::MD5 qw(md5_hex);
+
+my $nthreads = shift || 1;
+
+for my $tid (1 .. $nthreads) {
+ async {
+ print STDERR "Thread $tid running\n";
+ while (1) {
+ my $str;
+ $str .= ('0' .. '9', 'a' .. 'f')[rand 16] for 1..32;
+ return $str if $str eq md5_hex($str);
+ }
+ };
+}
+
+while (1) {
+ if (my ($finished) = threads->list(threads::joinable)) {
+ my $match = $finished->join;
+ print "We have a winner: $match\n";
+ $_->detach for threads->list;
+ exit;
+ }
+ sleep 1;
+}
+
View
18 perl/perl-Kurt-Maier.pl
@@ -0,0 +1,18 @@
+#!/usr/bin/perl -w
+use strict; #because we care.
+# I like random; it seems sporting.
+
+use Digest::MD5 qw (md5_hex);
+use String::Random qw (random_string);
+my ($this, $that);
+my $pattern = "00000000000000000000000000000000";
+
+sub what_we_do {
+ $this = random_string($pattern, ['a'..'f', 0..9]);
+ $that = md5_hex($this);
+}
+
+do { what_we_do() } until $this eq $that;
+
+print $this, "\n";
+
Please sign in to comment.
Something went wrong with that request. Please try again.