This library offers basic cryptographic facilities for Lua 5.0: a hash (digest) function, an a pair crypt/decrypt. (download)
Computes the MD5 message-digest of the string
This function takes as input a message of arbitrary length and content
and returns as output a 128-bit "fingerprint" (or "message digest")
of the input.
The output is formated as a binary string with 16 characters.
It is conjectured that it is computationally infeasible to produce
two messages having the same message digest, or to produce any
message having a given pre-specified target message digest.
but returns its value as a string of 32 hexadecimal digits.
md5.crypt (message, key [,seed])
Encrypts a string, using MD5 in CFB (Cipher-feedback mode).
message is an arbitrary binary string to be encrypted.
key is an arbitrary binary string to be used as a key.
seed is an arbitrary binary string to be used as a seed;
Returns the cyphertext (as a binary string).
If no seed is provided,
the function uses the result of
os.time() as a seed.
It is recommended that you use different seeds for each message;
the seed itself is not private, and should contain no private data,
because it goes plain in the beginning of the encrypted message.
The length of the cyphertext is the length of the message plus the length of the seed plus one.
md5.decrypt (message, key)
Decrypts a string.
message must be the result of a previous call
seed, we have that
md5.decrypt(md5.crypt(msg, key, seed), key) == msg
md5.exor (s1, s2)
Does a bit-a-bit exclusive or of strings
Both strings must have the same length,
which will be also the length of the resulting string.
int luaopen_md5 (lua_State *L);
Opens the library: Registers the above Lua functions in the given state.
void md5 (const char *message, long len, char *output);
Computes the MD5 message-digest of
len is the length of
output is a buffer that receives the result;
it must have at least 16 bytes (128 bits).
.dll, etc.) with files
md5lib.c. (There is a
makefilefor Linux and similar systems.)
md5.luato point to it.
md5.luain a directory of your
$Id: md5.html,v 1.4 2003/04/28 16:40:42 roberto Exp $