Jelajahi Sumber

* Add cmd_hash which returns the MD5, SHA1 and SHA256 of the given string.

Bryan Drewery 16 tahun lalu
induk
melakukan
52ca9a43fe
3 mengubah file dengan 28 tambahan dan 8 penghapusan
  1. 1 0
      doc/UPDATES
  2. 13 8
      doc/help.txt
  3. 14 0
      src/cmds.c

+ 1 - 0
doc/UPDATES

@@ -1,5 +1,6 @@
 * Added SHA256 support (cmd_sha256, Auth cmd: sha256)
 * Add cmd_encrypt_fish and cmd_decrypt_fish which uses eggdrop's blowfish (same as FiSH)
+* Add cmd_hash which returns the MD5, SHA1 and SHA256 of the given string.
 
 1.3 - http://wraith.botpack.net/milestone/1.3
 * Binary / shell / startup changes

+ 13 - 8
doc/help.txt

@@ -901,14 +901,14 @@ See also: down
 ###  $bdecrypt$b <key> <string>
    Decrypts the string using the specified key.
  
-See also: decrypt_fish, encrypt, encrypt_fish, randstring, md5, sha1, sha256
+See also: decrypt_fish, encrypt, encrypt_fish, randstring, md5, sha1, sha256, hash
 ::decrypt_fish
 ###  $bdecrypt_fish$b <key> <string>
    Decrypts the string using the specified key.
  
    This algorithm is eggdrop's blowfish, same as FiSH.
  
-See also: decrypt, encrypt, encrypt_fish, randstring, md5, sha1, sha256
+See also: decrypt, encrypt, encrypt_fish, randstring, md5, sha1, sha256, hash
 :leaf:deluser
 ###  $bdeluser$b <nickname>
    Deletes a user record for a user on the channel, using their
@@ -975,14 +975,14 @@ See also: color, console, login, page, strip
 ###  $bencrypt$b <key> <string>
    Encrypts the string using the specified key.
  
-See also: encrypt_fish, decrypt, decrypt_fish, randstring, md5, sha1, sha256
+See also: encrypt_fish, decrypt, decrypt_fish, randstring, md5, sha1, sha256, hash
 ::encrypt_fish
 ###  $bencrypt_fish$b <key> <string>
    Encrypts the string using the specified key.
  
    This algorithm is eggdrop's blowfish, same as FiSH.
  
-See also: encrypt, decrypt, decrypt_fish, randstring, md5, sha1, sha256
+See also: encrypt, decrypt, decrypt_fish, randstring, md5, sha1, sha256, hash
 ::exec:
 ###  $bexec$b <params>
    The bot will execute the specified program with each param specified,
@@ -1059,6 +1059,11 @@ See also: console, channels%{+m}, status%{-}
    Perm owners may not change their handle without recompiling binaries first. 
  
 See also: newpass%{+mi}, chhandle, chpass%{-}%{+n}, chsecpass%{-}
+::hash
+###  $bhash$b <string>
+   Returns the MD5, SHA1, and SHA256 hash of the specified string.
+ 
+See also: randstring, md5, sha1, sha256, encrypt, encrypt_fish, decrypt, decrypt_fish
 ::help:
 ###  $bhelp$b [cmd]
    Alone, will show all cmds that match your flags. With a cmd it will show
@@ -1285,7 +1290,7 @@ See also: match
 ###  $bmd5$b <string>
    Returns the MD5 hash of the specified string.
  
-See also: randstring, sha1, sha256, encrypt, encrypt_fish, decrypt, decrypt_fish
+See also: randstring, sha1, sha256, hash, encrypt, encrypt_fish, decrypt, decrypt_fish
 ::me
 ###  $bme$b <text>
    Performs an action on the party line. This appears as "* bryan is leaving",
@@ -1464,7 +1469,7 @@ See also: color, console, echo, login, strip
 ###  $brandstring$b <len>
    Displays a random string of length 'len' up to 300 chars.
  
-See also: md5, sha1, sha256, encrypt, encrypt_fish, decrypt, decrypt_fish
+See also: md5, sha1, sha256, hash, encrypt, encrypt_fish, decrypt, decrypt_fish
 ::rehash
 ###  $brehash$b 
    Don't use this cmd, it doesn't do what you think it does, and can result
@@ -1676,12 +1681,12 @@ See also: botset
 ###  $bsha1$b <string>
    Returns the SHA1 hash of the specified string.
  
-See also: randstring, md5, sha256, encrypt, encrypt_fish, decrypt, decrypt_fish
+See also: randstring, md5, sha256, hash, encrypt, encrypt_fish, decrypt, decrypt_fish
 ::sha256
 ###  $bsha256$b <string>
    Returns the SHA256 hash of the specified string.
  
-See also: randstring, md5, sha1, encrypt, encrypt_fish, decrypt, decrypt_fish
+See also: randstring, md5, sha1, hash, encrypt, encrypt_fish, decrypt, decrypt_fish
 ::simul
 ###  $bsimul$b <handle> <text>
    This allows you to simulate the specified handle typing the given text.

+ 14 - 0
src/cmds.c

@@ -1613,6 +1613,19 @@ static void cmd_randstring(int idx, char *par)
     dprintf(idx, "Too long, must be <= 300\n");
 }
 
+static void cmd_hash(int idx, char *par)
+{
+  if (!par[0]) {
+    dprintf(idx, "Usage: hash <string>\n");
+    return;
+  }
+
+  putlog(LOG_CMDS, "*", "#%s# hash ...", dcc[idx].nick);
+  dprintf(idx, "MD5(%s) = %s\n", par, MD5(par));
+  dprintf(idx, "SHA1(%s) = %s\n", par, SHA1(par));
+  dprintf(idx, "SHA256(%s) = %s\n", par, SHA256(par));
+}
+
 static void cmd_md5(int idx, char *par)
 {
   if (!par[0]) {
@@ -4623,6 +4636,7 @@ cmd_t C_dcc[] =
   {"test",		"",	(Function) cmd_test,		NULL, 0},
   {"botlink",		"a",	(Function) cmd_botlink,		NULL, 0},
   {"randstring", 	"", 	(Function) cmd_randstring, 	NULL, AUTH_ALL},
+  {"hash",		"",	(Function) cmd_hash,		NULL, AUTH_ALL},
   {"md5",		"",	(Function) cmd_md5,		NULL, AUTH_ALL},
   {"sha1",		"",	(Function) cmd_sha1,		NULL, AUTH_ALL},
   {"sha256",		"",	(Function) cmd_sha256,		NULL, AUTH_ALL},