Skip to content

Commit d2fccb0

Browse files
committed
Init!
0 parents  commit d2fccb0

File tree

7 files changed

+598
-0
lines changed

7 files changed

+598
-0
lines changed

.github/SECURITY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Security Policy
2+
3+
Please note that I only support the last version of this module.
4+
5+
If you believe to have found a vulnerability in blake2-d, I strongly advise you
6+
to draft a new security advisory under Security > Securitiy advisories.
7+
8+
If that's not alright with you, you can always send me an email (found on my profile).

.github/workflows/d.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: D
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: dlang-community/setup-dlang@v1
15+
- name: 'Build'
16+
run: dub build --compiler=dmd
17+
- name: 'Test'
18+
run: dub test --compiler=dmd

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.dub
2+
dub.selections.json
3+
docs.json
4+
__dummy.html
5+
docs/
6+
/blake2-d
7+
blake2-d.so
8+
blake2-d.dylib
9+
blake2-d.dll
10+
blake2-d.a
11+
blake2-d.lib
12+
blake2-d-test-*
13+
*.exe
14+
*.o
15+
*.obj
16+
*.lst

LICENSE

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
Boost Software License - Version 1.0 - August 17th, 2003
2+
3+
Permission is hereby granted, free of charge, to any person or organization
4+
obtaining a copy of the software and accompanying documentation covered by
5+
this license (the "Software") to use, reproduce, display, distribute,
6+
execute, and transmit the Software, and to prepare derivative works of the
7+
Software, and to permit third-parties to whom the Software is furnished to
8+
do so, all subject to the following:
9+
10+
The copyright notices in the Software and this entire statement, including
11+
the above license grant, this restriction and the following disclaimer,
12+
must be included in all copies of the Software, in whole or in part, and
13+
all derivative works of the Software, unless such copies or derivative
14+
works are solely in the form of machine-executable object code generated by
15+
a source language processor.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19+
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
20+
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
21+
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
22+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23+
DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# blake2-d
2+
3+
BLAKE2 library written in D implementing the BLAKE2b and BLAKE2s hashing
4+
algorithms and is compatible with the Phobos Digest API (std.digest).
5+
6+
BLAKE2 was introduced in 2015 as IETF RFC 7693. You can visit
7+
[the website](https://www.blake2.net/) for more information.
8+
9+
This module:
10+
11+
- [x] Supports BLAKE2b-512 and BLAKE2s-256.
12+
- [x] Supports custom hash sizes.
13+
- [ ] Supports HMAC. (WIP!)
14+
15+
Compatible and tested with DMD, GDC, and LDC.
16+
17+
Pull Requests accepted.
18+
19+
**If you would like to disclose a vulnerability, please consult [SECURITY.md](../master/.github/SECURITY.md).**
20+
21+
# Usage
22+
23+
To include it in your project, simply import the `blake2d` package.
24+
25+
## Digest API
26+
27+
If you are unfamiliar with the Digest API, here is a quick summary.
28+
29+
Two APIs are available: Template API and OOP API.
30+
31+
### Template API
32+
33+
The template API uses a structure template and is a good choice if your
34+
application only plans to support one digest algorithm.
35+
36+
```d
37+
// NOTE: hexString is from std.conv
38+
BLAKE2b512 b2b512;
39+
b2b512.put("abc");
40+
assert(b2b512.finish() == cast(ubyte[]) hexString!(
41+
"ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d1"~
42+
"7d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"
43+
));
44+
b2b512.start(); // reset
45+
b2b512.put("abcdef");
46+
assert(b2b512.finish() == cast(ubyte[]) hexString!(
47+
"dde410524e3569b303e494aa82a3afb3e426f9df24c1398e9ff87aafbc2f5b7b"~
48+
"3c1a4c9400409de3b45d37a00e5eae2a93cc9c4a108b00f05217d41a424d2b8a");
49+
```
50+
51+
### OOP API
52+
53+
The OOP API uses a class (object) implementation and is a good choice if
54+
your application plans to support one or more digest algorithms.
55+
56+
```d
57+
// NOTE: hexString is from std.conv
58+
Digest dgst = new BLAKE2b512Digest();
59+
dgst.put("abc");
60+
assert(dgst.finish() == cast(ubyte[]) hexString!(
61+
"ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d1"~
62+
"7d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"
63+
));
64+
dgst.start(); // reset
65+
dgst.put("abcdef");
66+
assert(dgst.finish() == cast(ubyte[]) hexString!(
67+
"dde410524e3569b303e494aa82a3afb3e426f9df24c1398e9ff87aafbc2f5b7b"~
68+
"3c1a4c9400409de3b45d37a00e5eae2a93cc9c4a108b00f05217d41a424d2b8a");
69+
```
70+
71+
There are numerous ways to avoid GC allocation. For example when only using a
72+
digest for a one-time use in a short scope, there's `std.typecons.scoped`.
73+
74+
# License
75+
76+
Published under the Boost License 1.0.

dub.sdl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name "blake2-d"
2+
description "BLAKE2s and BLAKEb implementations."
3+
authors "dd86k <dd@dax.moe>"
4+
copyright "Copyright © 2021, dd86k"
5+
license "BSL-1.0"

0 commit comments

Comments
 (0)