blake2-d 0.1.0
BLAKE2s and BLAKEb implementations.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
blake2-d
BLAKE2 library written in D implementing the BLAKE2b and BLAKE2s hashing algorithms and is compatible with the Phobos Digest API (std.digest).
BLAKE2 was introduced in 2015 as IETF RFC 7693. You can visit the website for more information.
This module:
- [x] Supports BLAKE2b-512 and BLAKE2s-256.
- [x] Supports custom hash sizes.
- [ ] Supports HMAC. (WIP!)
Compatible and tested with DMD, GDC, and LDC.
Pull Requests accepted.
If you would like to disclose a vulnerability, please consult [SECURITY.md](../master/.github/SECURITY.md).
Usage
To include it in your project, simply import the blake2d
package.
Digest API
If you are unfamiliar with the Digest API, here is a quick summary.
Two APIs are available: Template API and OOP API.
Template API
The template API uses a structure template and is a good choice if your application only plans to support one digest algorithm.
// NOTE: hexString is from std.conv
BLAKE2b512 b2b512;
b2b512.put("abc");
assert(b2b512.finish() == cast(ubyte[]) hexString!(
"ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d1"~
"7d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"
));
b2b512.start(); // reset
b2b512.put("abcdef");
assert(b2b512.finish() == cast(ubyte[]) hexString!(
"dde410524e3569b303e494aa82a3afb3e426f9df24c1398e9ff87aafbc2f5b7b"~
"3c1a4c9400409de3b45d37a00e5eae2a93cc9c4a108b00f05217d41a424d2b8a");
OOP API
The OOP API uses a class (object) implementation and is a good choice if your application plans to support one or more digest algorithms.
// NOTE: hexString is from std.conv
Digest dgst = new BLAKE2b512Digest();
dgst.put("abc");
assert(dgst.finish() == cast(ubyte[]) hexString!(
"ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d1"~
"7d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"
));
dgst.start(); // reset
dgst.put("abcdef");
assert(dgst.finish() == cast(ubyte[]) hexString!(
"dde410524e3569b303e494aa82a3afb3e426f9df24c1398e9ff87aafbc2f5b7b"~
"3c1a4c9400409de3b45d37a00e5eae2a93cc9c4a108b00f05217d41a424d2b8a");
There are numerous ways to avoid GC allocation. For example when only using a
digest for a one-time use in a short scope, there's std.typecons.scoped
.
License
Published under the Boost License 1.0.
- Registered by dd
- 0.1.0 released 3 years ago
- dd86k/blake2-d
- BSL-1.0
- Copyright © 2021, dd86k
- Authors:
- Dependencies:
- none
- Versions:
-
0.3.0 2022-Aug-26 0.2.0 2022-Jan-01 0.1.0 2021-Dec-23 ~master 2023-Dec-18 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
1 downloads this month
-
77 downloads total
-
- Score:
- 0.5
- Short URL:
- blake2-d.dub.pm