SHA256 in Perl 6 using NativeCall
C Perl 6 Makefile
Switch branches/tags
Nothing to show
Permalink
Failed to load latest commit information.
lib/Digest/SHA256 Initial commit Sep 15, 2017
src Use unsigned chars for uint8 Sep 15, 2017
t Add author test, fix license Sep 15, 2017
.gitignore Initial commit Sep 15, 2017
.travis.yml Add travis configuration Sep 15, 2017
Build.pm added Build.pm Sep 15, 2017
Configure.pl6 Initial commit Sep 15, 2017
LICENSE Initial commit Sep 15, 2017
META6.json 0.02 Sep 15, 2017
Makefile.in Initial commit Sep 15, 2017
README.md Initial commit Sep 15, 2017

README.md

Digest::SHA256::Native

Fast SHA256 computation using NativeCall to C.

Build Status

Synopsis

use Digest::SHA256::Native;

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

Description

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

sha256 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::SHA256::Native;

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

f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8

References

The implementation is mostly taken from Brad Conte's crypto-algorithms.