Algorithm for decoding SHA1 hashes
Nov 3, 2011 at 7:37pm UTC
Here's a small algorithm I made to decode SHA1 hashes. Unfortunately it's performance is very poor.
How can I drastically speed it up? Help would be really appreciated =)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
void DecodeSHA1() {
char NewHash[41]; // Charater array that will be constantly holding new hashes.
char Hash[41] = "4170ac2a2782a1516fe9e13d7322ae482c1bd594" ; // Example hash
char * Symbol = "0123456789abcdefghijklmnopqrstuvwxyz" ; // List of possible symbols
int l = Lenght(Symbol);
char String1[2];
/* Goes from 0 to z */
for (int i1 = 0; i1 < l; i1++) {
String1[0] = Symbol[i1];
// NewHash is assigned the hash value of String1
if (Compare(Hash,NewHash)) {
printf("Found collision: %s\n" ,String1);
return ;
}
}
char String2[3];
/* Goes from 00 to zz */
for (int i1 = 0; i1 < l; i1++) {
String2[0] = Symbol[i1];
for (int i2 = 0; i2 < l; i2++) {
String2[1] = Symbol[i2];
// NewHash is assigned the hash value of String2
if (Compare(Hash,NewHash)) {
printf("Found collision: %s\n" ,String2);
return ;
}
}
}
char String3[4];
/* Goes from 000 to zzz */
for (int i1 = 0; i1 < l; i1++) {
String3[0] = Symbol[i1];
for (int i2 = 0; i2 < l; i2++) {
String3[1] = Symbol[i2];
for (int i3 = 0; i3 < l; i3++) {
String3[2] = Symbol[i3];
// NewHash is assigned the hash value of String3
if (Compare(Hash,NewHash)) {
printf("Found collision: %s\n" ,String3);
return ;
}
}
}
}
char String4[5];
/* Goes from 0000 to zzzz */
for (int i1 = 0; i1 < l; i1++) {
String4[0] = Symbol[i1];
for (int i2 = 0; i2 < l; i2++) {
String4[1] = Symbol[i2];
for (int i3 = 0; i3 < l; i3++) {
String4[2] = Symbol[i3];
for (int i4 = 0; i4 < l; i4++) {
String4[3] = Symbol[i4];
// NewHash is assigned the hash value of String4
if (Compare(Hash,NewHash)) {
printf("Found collision: %s\n" ,String4);
return ;
}
}
}
}
}
printf("No collision found.\n" );
}
Nov 3, 2011 at 7:49pm UTC
You
could use threads on a multi-core CPU but generally speaking Brute Forcing (that is the term for what you are doing here) is not a fast process at all. That is after all the reason encryption is effective, if just anybody could brute force their way through encryption then there wouldn't be billions of dollars of research, and multi-millions dollar rewards related to it every year.
Not to go all "Hollywood" on you, but in cases of brute force decryption a Beowulf Cluster is a vaid option:
http://en.wikipedia.org/wiki/Beowulf_cluster
I'm glad to see someone else that is interested in this topic, good luck on your research.
Topic archived. No new replies allowed.