diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-08-23 19:32:15 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-08-23 19:32:15 -0700 |
commit | 10fd98a804097002f9331e48fc6f84f3f3d8f3e2 (patch) | |
tree | df74904a86469a4d2dcde22a890053d0fba6d073 /txr.1 | |
parent | 0dd1d1a586fcfcf11e0b1c926c8be9c4c8d525be (diff) | |
download | txr-10fd98a804097002f9331e48fc6f84f3f3d8f3e2.tar.gz txr-10fd98a804097002f9331e48fc6f84f3f3d8f3e2.tar.bz2 txr-10fd98a804097002f9331e48fc6f84f3f3d8f3e2.zip |
New: MD5 digest functions.
* Makefile (OBJS): New object file, chksums/md5.o.
* chksum.c (sha256_ensure_buf): Renamed to chksum_ensure_buf
and made generic so MD5 code can borrow it.
(sha256_stream, sha256): Call chksum_ensure_buf instead of
sha256_ensure_buf, passing in new length and hash name
parameters.
(md5_stream_impl, md5_buf, md5_str): New static functions.
(md5_stream, md5): New functions.
(chksum_init): Register md5-stream and md5 intrinsics.
* chksum.h (md5_stream, md5): Declared.
* chksums/md5.c, chksums/md5.h: New files.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 37 |
1 files changed, 29 insertions, 8 deletions
@@ -52306,9 +52306,10 @@ which constitute its UTF-8 representation. The CRC-32 is returned as a non-negative integer. -.coNP Function @ sha256-stream +.coNP Functions @ sha256-stream and @ md5-stream .synb .mets (sha256-stream < stream >> [ nbytes <> [ buf ]]) +.mets (md5-stream < stream >> [ nbytes <> [ buf ]]) .syne .desc The @@ -52317,6 +52318,11 @@ calculates the NIST SHA-256 digest over the bytes read from .metn stream , starting at the stream's current position. +The +.code md5-stream +function calculates the MD5 digest, using the +RSA Data Security, Inc. MD5 Message-Digest Algorithm. + If the .meta nbytes argument is specified, it should be a nonnegative @@ -52326,15 +52332,20 @@ until the end of the stream. If the .meta buf -argument is omitted, the 256 bit digest value is returned as a new, -32-byte-long buffer object. If the +argument is omitted, the digest value is returned as a new, +buffer object. This buffer is 32 bytes long in the case of SHA-256, +holding a 256-bit digest, and 16 bytes long in the case of MD5, +holding a 128-bit digest. +If the .meta buf -argument is specified, it must be a buffer that is at least 32 bytes long. +argument is specified, it must be a buffer that is at least 16 bytes long +in the case of MD5, and at least 32 bytes long in the case of SHA-256. The hash is placed into that buffer, which is then returned. -.coNP Function @ sha256 +.coNP Functions @ sha256 and @ md5 .synb .mets (sha256 < obj <> [ buf ]) +.mets (md5 < obj <> [ buf ]) .syne .desc The @@ -52343,6 +52354,12 @@ function calculates the NIST SHA-256 digest over .metn obj , which may be a character string or a buffer. +Similarly, the +.code md5 +functions calculates the MD5 digest over +.metn obj , +using the RSA Data Security, Inc. MD5 Message-Digest Algorithm. + If .meta obj is a buffer, then the digest is calculated over all of the bytes contained @@ -52355,10 +52372,14 @@ which constitute its UTF-8 representation. If the .meta buf -argument is omitted, the 256 bit digest value is returned as a new, -32-byte-long buffer object. If the +argument is omitted, the digest value is returned as a new, +buffer object. This buffer is 32 bytes long in the case of SHA-256, +holding a 256-bit digest, and 16 bytes long in the case of MD5, +holding a 128-bit digest. +If the .meta buf -argument is specified, it must be a buffer that is at least 32 bytes long. +argument is specified, it must be a buffer that is at least 16 bytes long +in the case of MD5, and at least 32 bytes long in the case of SHA-256. The hash is placed into that buffer, which is then returned. .SS* The Awk Utility |