Skip to content

Instantly share code, notes, and snippets.

@guyht
Created July 1, 2011 17:02
Show Gist options
  • Save guyht/1058953 to your computer and use it in GitHub Desktop.
Save guyht/1058953 to your computer and use it in GitHub Desktop.
SHA1 test
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <vector>
#include <openssl/sha.h>
using namespace std;
int main()
{
static const char chars[] = "abcdefghijklmnopqrstuvwxyz";
static const char length = 6;
static const int total = 26^length;
int i1 = 0;
int i2 = 0;
int i3 = 0;
int i4 = 0;
int i5 = 0;
int i6 = 0;
unsigned char ibuf[6];
unsigned char obuf[20];
char buff[6];
unsigned int len;
int n=0.1;
int perc=0;
time_t seconds = time (NULL);
for(i1=0;i1<26;i1++) {
for(i2=0;i2<26;i2++) {
for(i3=0;i3<26;i3++) {
for(i4=0;i4<26;i4++) {
for(i5=0;i5<26;i5++) {
for(i6=0;i6<26;i6++) {
len = sprintf(buff, "%c%c%c%c%c%c", chars[i1], chars[i2], chars[i3], chars[i4], chars[i5], chars[i6]);
memcpy(ibuf, buff, 6);
//printf("%c%c%c%c%c%c", ibuf[0], ibuf[1], ibuf[2], ibuf[3], ibuf[4], ibuf[5]);
SHA1(ibuf, len, obuf);
for(int i=0;i<20;i++) {
printf("%x ", obuf[i]);
}
printf("\n");
}
}
}
}
}
}
time_t finish = (time (NULL) - seconds);
printf("%d hashes in %d seconds", n, finish);
printf("\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment