项目作者: bduggan

项目描述 :
SHA256 in Perl 6 using NativeCall
高级语言: C
项目地址: git://github.com/bduggan/p6-digest-sha256-native.git
创建时间: 2017-09-15T15:05:51Z
项目社区:https://github.com/bduggan/p6-digest-sha256-native

开源协议:Artistic License 2.0

下载


Digest::SHA256::Native

Fast SHA256 computation using NativeCall to C.

OS tests
LinuxNix
MacOS
linux

Synopsis

  1. use Digest::SHA256::Native;
  2. say sha256-hex("The quick brown fox jumps over the lazy dog");
  3. say sha256-hex("The quick brown fox jumps over the lazy dog".encode);
  4. say sha256("The quick brown fox jumps over the lazy dog")».fmt('%02x').join;
  1. d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
  2. d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592
  3. 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:

  1. use Digest::HMAC;
  2. use Digest::SHA256::Native;
  3. 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.