Guest User

passgen

a guest
Apr 10th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.80 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <openssl/md5.h>
  4. #include <glib.h>
  5. #include <stdlib.h>
  6. int main(int argc, char * argv[])
  7. {
  8.         if(argc<2){
  9.                 printf("usage: passgen [password]\n");
  10.                 exit(0);
  11.         }
  12.         char * buffer = malloc(255);
  13.         strncpy(buffer, (const char *)argv[1], 255);
  14.         unsigned char * hash = MD5((unsigned const char *)argv[1], strlen(argv[1]), NULL);
  15.         int i = strlen(hash);
  16.         char * base64 = (char *)g_base64_encode((const guchar *)hash, (gsize)i);
  17.         i = strlen(base64);
  18.         while(i){
  19.                 base64[i]-=10;
  20.                 i--;
  21.         }
  22.         printf("%s", base64); printf("\n");
  23. }
  24. // gcc `pkg-config --cflags glib-2.0 libssl` passgen.c -o passgen `pkg-config --libs glib-2.0 libssl`
Advertisement
Add Comment
Please, Sign In to add comment