=head1 NAME md5 - MD5 cryptographic facilities (MD5) =head1 OVERVIEW MD5 offers basic cryptographic facilities for Lua (L) 5.0 and 5.1: a hash (digest) function and a pair crypt/decrypt. =head1 DOWNLOAD MD5 can be downloaded in source code from its LuaForge (L) page. If you are using LuaBinaries (L). 5.0.2 Release 2, a Windows precompiled version of MD5 can also be found at the same LuaForge page. =head1 BUILDING MD5 could be built to Lua 5.0 or to Lua 5.1. In both cases, the language library and headers files for the target version must be installed properly. MD5 offers a Makefile and a separate configuration file, C, which should be edited to suit the particularities of the target platform before running C. The file has some definitions like paths to the external libraries, compiler options and the like. One important definition is the Lua version, which is not obtained from the installed software. =head1 INSTALLATION The compiled binary file should be copied to a directory called C in your C path (L) with the name C. Lua 5.0 users should also install Compat-5.1 (L). Windows users can use the binary version of MD5 available at LuaForge (L). The file C should be copied to a directory in your Lua path (L). =head1 REFERENCE - Lua API All MD5 functions are registered inside a table C. =head2 C md5.sum (message) Computes the MD5 message-digest of the string C. 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. (see RFC 1321 (L)) =head2 C md5.sumhexa (message) Similar to C, but returns its value as a string of 32 hexadecimal digits. =head2 C md5.crypt (message, key [,seed]) Encrypts a string, using MD5 in CFB (Cipher-feedback mode). C is an arbitrary binary string to be encrypted. C is an arbitrary binary string to be used as a key. C 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 L() 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. =head2 C md5.decrypt (message, key) Decrypts a string. The input C must be the result of a previous call to C. For any C, C, and C, we have that =head2 C md5.decrypt(md5.crypt(msg, key, seed), key) == msg =head2 C md5.exor (s1, s2) Does a bit-a-bit exclusive or of strings C and C. Both strings must have the same length, which will be also the length of the resulting string. =head1 REFERENCE - C API The following functions are declared in C =head2 C int luaopen_md5_core (lua_State *L) Opens the library and registers the above Lua functions in the given state. =head2 C void md5 (const char *message, long len, char *output) Computes the MD5 message-digest of C. C is the length of C. C is a buffer that receives the result; it must have at least 16 bytes (128 bits). =head1 VERSION MD5 version 1.0.1 for both Lua 5.0 and Lua 5.1 is now available for download. =head1 HISTORY =over 4 =item Version 1.0.1 [21/Aug/2006] Adapted to work with both Lua 5.0 and Lua 5.1. =item Version 1.0.0 First public version. =back =head1 CREDITS MD5 was designed and implemented by Roberto Ierusalimschy and Marcela OzErio Suarez. The current distribution was packed by TomEs Guisasola as part of the Kepler Project (L). =head1 CONTACT For more information please contact us (info-NO-SPAM-THANKS@keplerproject.org). Comments are welcome! You can also reach other Kepler developers and users on the Kepler Project mailing list (L). =head1 LICENSE MD5 is free software and uses the same license as Lua. MD5 is free software: it can be used for both academic and commercial purposes at absolutely no cost. There are no royalties or GNU-like "copyleft" restrictions. MD5 qualifies as Open Source (L) software. Its licenses are compatible with GPL (L). MD5 is not in the public domain and PUC-Rio keeps its copyright. The legal details are below. The spirit of the license is that you are free to use MD5 for any purpose at no cost without having to ask us. The only requirement is that if you do use MD5, then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation. MD5 was designed and implemented by Roberto Ierusalimschy and Marcela OzErio Suarez. The implementation is not derived from licensed software. ~~~~~ Copyright E 2003-2006 PUC-Rio. All rights reserved. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ~~~~~