-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Elliott Kember
committed
May 7, 2009
1 parent
b2867cf
commit 0d3437e
Showing
19 changed files
with
100 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'" |