SHA1 in Perl 6 using NativeCall
Branch: master
Clone or download
jnthn and bduggan Do not mutate input buffer when computing the SHA1
In some cases, the input that was to be SHA1'd would be modified, which
was something of a problem if you were, for example, hashing a buffer
and then writing it to a file: the content to be written to the file
was no longer what it originally was! This only seemed to happen if the
buffer was long enough; the case in the added test triggered the
now-fixed bug.
Latest commit e34d468 Feb 20, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib/Digest/SHA1
src Do not mutate input buffer when computing the SHA1 Feb 20, 2019
t Do not mutate input buffer when computing the SHA1 Feb 20, 2019
.gitignore init Oct 5, 2016
.travis.yml Replace panda with zef in travis.cfg Sep 11, 2017
Build.pm Added back Build.pm Sep 15, 2017
Configure.pl6 init Oct 5, 2016
LICENSE docs Oct 6, 2016
META6.json
Makefile.in Fix Makefile to work on Windows. Jan 9, 2017
README.md Fix status badge link in README Sep 11, 2017

README.md

Digest::SHA1::Native

Fast SHA1 computation using NativeCall to C.

Build Status

Synopsis

use Digest::SHA1::Native;

say sha1-hex("The quick brown fox jumps over the lazy dog");
say sha1-hex("The quick brown fox jumps over the lazy dog".encode);
say sha1("The quick brown fox jumps over the lazy dog")».fmt('%02x').join;
2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
2fd4e1c67a2d28fced849ee1bb76e7391b93eb12
2fd4e1c67a2d28fced849ee1bb76e7391b93eb12

Description

sha1-hex accepts a string or bytes (a Buf or Blob) and returns a hex string.

sha1 converts the hex into binary (i.e. it returns a Blob).

Examples

From https://en.wikipedia.org/wiki/Hash-based_message_authentication_code#Examples:

use Digest::HMAC;
use Digest::SHA1::Native;

say hmac-hex("key","The quick brown fox jumps over the lazy dog",&sha1);

de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9