1
0
Эх сурвалжийг харах

* Added some stupid stuff for console crypting for future use

svn: 1913
Bryan Drewery 21 жил өмнө
parent
commit
758beb24e5
3 өөрчлөгдсөн 38 нэмэгдсэн , 1 устгасан
  1. 30 0
      src/crypt.c
  2. 1 0
      src/crypt.h
  3. 7 1
      src/main.c

+ 30 - 0
src/crypt.c

@@ -329,3 +329,33 @@ char *btoh(const unsigned char *md, size_t len)
   ret = buf;
   return ret;
 }
+#ifdef k
+void do_crypt_console()
+{
+  char inbuf[1024] = "";
+  int which = 5;
+  char *p = NULL;
+
+  printf("Crypt menu:\n");
+  printf("-----------\n");
+  printf("1) String\n");
+  printf("2) File\n");
+
+  printf("1) MD5\n");
+  printf("2) SHA1\n");
+  printf("3) AES256 (binary)\n");
+  printf("4) AES256+base64\n");
+  printf("5) exit\n");
+  printf("\n");
+  printf("[5]: ");
+
+  fgets(inbuf, sizeof(inbuf), stdin);
+  if ((p = strchr(inbuf, '\n')))
+    *p = 0;
+
+  which = atoi(inbuf);
+
+  switch (which) {
+    case 
+}
+#endif

+ 1 - 0
src/crypt.h

@@ -26,5 +26,6 @@ int lfprintf (FILE *, const char *, ...) __attribute__((format(printf, 2, 3)));
 void Encrypt_File(char *, char *);
 void Decrypt_File(char *, char *);
 char *btoh(const unsigned char *, size_t);
+void do_crypt_console();
 
 #endif /* !_CRYPT_H */

+ 7 - 1
src/main.c

@@ -248,6 +248,7 @@ static void show_help()
   printf(format, "Option", "Description");
   printf(format, "------", "-----------");
   printf(format, STR("-B <botnick>"), STR("Starts the specified bot"));
+  printf(format, STR("-c"), STR("Crypt/Hash functions (MD5/SHA1/AES256)"));
   printf(format, STR("-C"), STR("Config file editor [reads env: EDITOR]"));
   printf(format, STR("-e <infile> <outfile>"), STR("Encrypt infile to outfile"));
   printf(format, STR("-d <infile> <outfile>"), STR("Decrypt infile to outfile"));
@@ -269,7 +270,7 @@ static void show_help()
 }
 
 // leaf: BkLP
-#define PARSE_FLAGS "0234:B:Cd:De:Eg:G:k:L:P:hnr:stu:U:v"
+#define PARSE_FLAGS "0234:B:c:Cd:De:Eg:G:k:L:P:hnr:stu:U:v"
 #define FLAGS_CHECKPASS "CdDeEgGhknrtuUv"
 static void dtx_arg(int argc, char *argv[])
 {
@@ -299,6 +300,11 @@ static void dtx_arg(int argc, char *argv[])
         used_B = 1;
         strlcpy(origbotname, optarg, NICKLEN + 1);
         break;
+      case 'c':
+        printf("SHA1 (%s): %s\n", optarg, SHA1(optarg));
+//        do_crypt_console();
+        exit(0);
+        break;
       case 'C':
         do_confedit = 1;
         break;