beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luamd5 / md5.html
blob1f47c97128639dd78a9847a677805f1a5d34d006
1 <html><body>
2 <h1>Cryptographic Library for Lua 5.0</h1>
4 <p>
5 This library offers basic cryptographic facilities for Lua 5.0:
6 a hash (digest) function, an a pair crypt/decrypt.
7 (<a href=md5.tar.gz>download</a>)
10 <h2>Lua API</h2>
12 All functions are registered inside a table <code>md5</code>.
14 <ul>
16 <li><code>md5.sum (message)</code>
17 <p>
18 Computes the MD5 message-digest of the string <code>message</code>.
19 This function takes as input a message of arbitrary length and content
20 and returns as output a 128-bit "fingerprint" (or "message digest")
21 of the input.
22 The output is formated as a binary string with 16 characters.
23 It is conjectured that it is computationally infeasible to produce
24 two messages having the same message digest, or to produce any
25 message having a given pre-specified target message digest.
26 (see <a href="ftp://ftp.isi.edu/in-notes/rfc1321.txt">
27 RFC 1321</a>)
28 <p>
30 <li><code>md5.sumhexa (message)</code>
31 <p>
32 Similar to <code>md5.sum</code>,
33 but returns its value as a string of 32 hexadecimal digits.
35 <li><code>md5.crypt (message, key [,seed])</code>
36 <p>
37 Encrypts a string, using MD5 in CFB (Cipher-feedback mode).
38 <code>message</code> is an arbitrary binary string to be encrypted.
39 <code>key</code> is an arbitrary binary string to be used as a key.
40 <code>seed</code> is an arbitrary binary string to be used as a seed;
41 Returns the cyphertext (as a binary string).
43 <p>
44 If no seed is provided,
45 the function uses the result of <code>os.time()</code> as a seed.
46 It is recommended that you use different seeds for each message;
47 the seed itself is not private, and should contain no private data,
48 because it goes plain in the beginning of the encrypted message.
50 <p>
51 The length of the cyphertext is the length of the message plus the
52 length of the seed plus one.
53 <p>
55 <li><code>md5.decrypt (message, key)</code>
56 <p>
57 Decrypts a string.
58 The input <code>message</code> must be the result of a previous call
59 to <code>crypt</code>.
60 For any <code>msg</code>, <code>key</code>,
61 and <code>seed</code>, we have that
62 <pre>
63 md5.decrypt(md5.crypt(msg, key, seed), key) == msg
64 </pre>
65 <p>
67 <li><code>md5.exor (s1, s2)</code>
68 <p>
69 Does a bit-a-bit exclusive or of strings <code>s1</code> and <code>s2</code>.
70 Both strings must have the same length,
71 which will be also the length of the resulting string.
72 <p>
74 </ul>
77 <h2>C API</h2>
79 The following functions are declared in <code>md5.h</code>
80 <ul>
82 <li><code>int luaopen_md5 (lua_State *L);</code>
83 <p>
84 Opens the library:
85 Registers the above Lua functions in the given state.
86 <p>
88 <li><code>void md5 (const char *message, long len, char *output);</code>
89 <p>
90 Computes the MD5 message-digest of <code>message</code>.
91 <code>len</code> is the length of <code>message</code>.
92 <code>output</code> is a buffer that receives the result;
93 it must have at least 16 bytes (128 bits).
94 <p>
96 </ul>
98 <h2>INSTALL</h2>
100 The following instructions assume that your Lua installation has a dynamic
101 linking facility (function <code>loadlib</code>):
103 <ul>
105 <li>Build a shared library (<code>.so</code>, <code>.dll</code>, etc.)
106 with files <code>md5.c</code> and <code>md5lib.c</code>.
107 (There is a <code>makefile</code> for Linux and similar systems.)
109 <li>Put the shared library somewhere,
110 and edit file <code>md5.lua</code> to point to it.
112 <li>Put the file <code>md5.lua</code> in a directory of your
113 <code>LUA_PATH</code>.
115 </ul>
117 <p><br><small><em>
118 $Id: md5.html,v 1.4 2003/04/28 16:40:42 roberto Exp $
119 </em></small>
121 </body></html>