Guest User

Untitled

a guest
Apr 10th, 2016
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.08 KB | None | 0 0
  1. #include <string.h>
  2. #include <openssl/md5.h>
  3. #include <glib.h>
  4. #include <termios.h>
  5. #include <stdlib.h>
  6. #include <unistd.h>
  7.  
  8. int main(int argc, char * argv[])
  9. {
  10.         printf("enter password: ");
  11.         char * passwd = malloc(2048);
  12.         struct termios term, term_orig;
  13.         tcgetattr(STDIN_FILENO, &term);
  14.         term_orig = term;
  15.         term.c_lflag &= ~ECHO;
  16.         tcsetattr(STDIN_FILENO, TCSANOW, &term);
  17.         scanf("%s", passwd);
  18.         unsigned char * hash = MD5((unsigned const char *)passwd, strlen(passwd), NULL);
  19.         int i = strlen(hash);
  20.         char * base64 = (char *)g_base64_encode((const guchar *)hash, (gsize)i);
  21.         i = strlen(base64);
  22.         while(i){
  23.                 base64[i]-=10;
  24.                 i--;
  25.         }
  26.         tcsetattr(STDIN_FILENO, TCSANOW, &term_orig);
  27.         char * out = malloc(2048);
  28.         i = strlen(base64) - 3;
  29.         strncpy(out, (const char *)base64, i);
  30.         printf("\n%s", out); printf("\n");
  31. }
  32.  
  33. //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