Skip to content

Commit

Permalink
Moved into folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Elliott Kember committed May 7, 2009
1 parent b2867cf commit 0d3437e
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 18 deletions.
7 changes: 7 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Welcome to the Kember Identity script pool.

I've had so many entries that I've decided to put everything on GitHub.

Some of the scripts suck, and some are awesome. You can create your own using the rough syntax language-firstname-lastname.extension.

This should help for benchmarking.
File renamed without changes.
80 changes: 80 additions & 0 deletions c-sharp/csharp-Jostein-Kjønigsen.cs
Original file line number Diff line number Diff line change
@@ -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();
}

}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 0 additions & 18 deletions tcl.tcl

This file was deleted.

13 changes: 13 additions & 0 deletions tcl/tcl.tcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package require md5 2
set digits {0 1 2 3 4 5 6 7 8 9 A B C D E F}

# any init will do
set hx [::md5::md5 -hex {}]

while {$hx ne [::md5::md5 -hex $hx]} {
# bernoulli-like shift with random last hex-digit
set idx [expr {int(floor(16*rand()))}]
set hx [string range $hx 1 end][lindex $digits $idx]
}

puts "Found it! It is '$hx'"

0 comments on commit 0d3437e

Please sign in to comment.