Previous section
To contents
Next section
14.14.4 Hash Functions
Cryptographic hash functions are essential for many cryptographic
applications, and are also useful in other contexts. The Toolkit
includes the two most common, MD5 and SHA1. They have
the same methods.
- METHOD
- update
- SYNTAX
-
object o->update(string data);
- DESCRIPTION
-
Processes some more data. For convenience, this method returns the
object itself.
- METHOD
- digest
- SYNTAX
-
string o->digest();
- DESCRIPTION
-
Returns the hash value, or message digest, corresponding to all
the data that was previously passed to the update method. Also resets
the hash object, so that it can be used to process a new message.
- METHOD
- query_digest_size
- SYNTAX
-
int o->query_digest_size();
- DESCRIPTION
-
Returns the size, in octets, of the digests produced by this hash function.
To get the md5 hash of a string s, you would use
Crypto.md5()->update(s)->digest()
Previous section
To contents
Next section