summaryrefslogtreecommitdiff
path: root/src/MD4.c
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2013-02-17 11:21:38 -0800
committerDwayne Litzenberger <dlitz@dlitz.net>2013-02-17 20:07:02 -0800
commitfd398a28e3a227a539b264a9f1e11287b904c7da (patch)
tree9f1628ef88c17604f55ec0ad652b0e1fb3959f38 /src/MD4.c
parent0d8ea5ff1607a3d7ae544667bff99229954484ff (diff)
downloadpycrypto-fd398a28e3a227a539b264a9f1e11287b904c7da.tar.gz
Hash: Speed up initialization by removing pure-Python wrappershash-speedup-wip
The pure Python wrappers around Crypto.Hash.* were convenient, but they slowed down hash initialization by 4-7x. There is a speed trade-off here: The MD5 and SHA1 objects are just wrapped hashlib objects (or old-style md5/sha objects). To maintain API compatibility with the rest of PyCrypto, we still have to wrap them, so they're slower to initialize than the rest of the hash functions. If hashlib ever adds a .new() method, we will automatically use hashlib directly and gain the initialization speed-up.
Diffstat (limited to 'src/MD4.c')
-rw-r--r--src/MD4.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/MD4.c b/src/MD4.c
index d5c20f4..7e453a8 100644
--- a/src/MD4.c
+++ b/src/MD4.c
@@ -31,11 +31,27 @@
#include <string.h>
#include "pycrypto_compat.h"
-#define MODULE_NAME _MD4
-#define ALGORITHM_NAME "MD4"
+#define MODULE_NAME MD4
#define DIGEST_SIZE 16
#define BLOCK_SIZE 64
+static char MODULE__doc__[] =
+ "MD4 cryptographic hash algorithm.\n"
+ "\n"
+ "MD4 is specified in RFC1320_ and produces the 128 bit digest of a message.\n"
+ "\n"
+ " >>> from Crypto.Hash import MD4\n"
+ " >>>\n"
+ " >>> h = MD4.new()\n"
+ " >>> h.update(b'Hello')\n"
+ " >>> print h.hexdigest()\n"
+ "\n"
+ "MD4 stand for Message Digest version 4, and it was invented by Rivest in 1990.\n"
+ "\n"
+ "This algorithm is insecure. Do not use it for new designs.\n"
+ "\n"
+ ".. _RFC1320: http://tools.ietf.org/html/rfc1320\n";
+
typedef unsigned int U32;
typedef unsigned char U8;
#define U32_MAX (U32)4294967295