blake3-rb 0.1.0.pre10-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +139 -0
- data/lib/blake3-rb.rb +3 -0
- data/lib/digest/blake3/3.0/blake3_ext.so +0 -0
- data/lib/digest/blake3/3.1/blake3_ext.so +0 -0
- data/lib/digest/blake3/3.2/blake3_ext.so +0 -0
- data/lib/digest/blake3.rb +9 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fc9909be51de511c42d9939fdae449eb24008fa77a86bc407363a56765c6caad
|
4
|
+
data.tar.gz: 9f07739d2aa51141723bf65c5fb9fd07992d84c55862e0772b492e35e964eb42
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: abf803873ce5d36e8d82435dc9a526efc581e74d728283e626032170aa3c5b8d150397e250763f36fb59c202132d941d241f9800c4edc75f668f907c61f1d226
|
7
|
+
data.tar.gz: fae7d07ad43dabd28918a11583079269214c0189acfd6283151377a1f87aaa3ea26b7b1080795b0d26d7bdf4f1dd261c4e3c74b8bb8877577a6f2223de5fe75b
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2023 Shopify, Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
# `blake3-rb`
|
2
|
+
|
3
|
+
![Build Status](https://github.com/Shopify/blake3-ruby/workflows/CI/badge.svg)
|
4
|
+
|
5
|
+
Blake3 is a Ruby gem that provides a simple and efficient way to compute the Blake3 cryptographic hash function. This gem is designed to be easy to use and integrate into your Ruby projects using the Ruby [`digest` framework](https://github.com/ruby/digest).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "blake3-rb", github: "Shopify/blake3-rb"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
$ bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Here's a simple usage example:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
require "digest/blake3"
|
27
|
+
|
28
|
+
result = Digest::Blake3.hexdigest("your data here")
|
29
|
+
```
|
30
|
+
|
31
|
+
If you need to stream data:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
require "digest/blake3"
|
35
|
+
|
36
|
+
hasher = Digest::Blake3.new
|
37
|
+
hasher.update("your data here")
|
38
|
+
result = hasher.hexdigest
|
39
|
+
```
|
40
|
+
|
41
|
+
Or use the `<<` operator:
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
require "digest/blake3"
|
45
|
+
|
46
|
+
hasher = Digest::Blake3.new
|
47
|
+
hasher << "part1" << "part2"
|
48
|
+
result = hasher.hexdigest
|
49
|
+
```
|
50
|
+
|
51
|
+
### Base64 Digest
|
52
|
+
|
53
|
+
You can compute the Base64 digest of your data:
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
require "digest/blake3"
|
57
|
+
|
58
|
+
result = Digest::Blake3.base64digest("your data here")
|
59
|
+
```
|
60
|
+
|
61
|
+
### Equality
|
62
|
+
|
63
|
+
You can compare two digests for equality:
|
64
|
+
|
65
|
+
```ruby
|
66
|
+
require "digest/blake3"
|
67
|
+
|
68
|
+
digest_one = Digest::Blake3.new
|
69
|
+
digest_two = Digest::Blake3.new
|
70
|
+
|
71
|
+
digest_one.update("your data here")
|
72
|
+
digest_two.update("your data here")
|
73
|
+
|
74
|
+
if digest_one == digest_two
|
75
|
+
puts "Digests are equal"
|
76
|
+
else
|
77
|
+
puts "Digests are not equal"
|
78
|
+
end
|
79
|
+
```
|
80
|
+
|
81
|
+
You can compute the hash of a file:
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
require "digest/blake3"
|
85
|
+
|
86
|
+
result = Digest::Blake3.file("path/to/your/file")
|
87
|
+
```
|
88
|
+
|
89
|
+
## Benchmarks
|
90
|
+
|
91
|
+
Here are some benchmarks comparing this gem with other digests on `x86_64-linux`:
|
92
|
+
|
93
|
+
```bash
|
94
|
+
$ ruby bench/string.rb
|
95
|
+
...
|
96
|
+
Warming up --------------------------------------
|
97
|
+
Digest::SHA1 61.000 i/100ms
|
98
|
+
Digest::SHA256 21.000 i/100ms
|
99
|
+
Digest::MD5 58.000 i/100ms
|
100
|
+
Digest::Blake3 560.000 i/100ms
|
101
|
+
Calculating -------------------------------------
|
102
|
+
Digest::SHA1 612.174 (± 0.3%) i/s - 3.111k in 5.081922s
|
103
|
+
Digest::SHA256 215.281 (± 0.0%) i/s - 1.092k in 5.072453s
|
104
|
+
Digest::MD5 586.009 (± 0.3%) i/s - 2.958k in 5.047759s
|
105
|
+
Digest::Blake3 5.698k (± 0.6%) i/s - 28.560k in 5.012308s
|
106
|
+
|
107
|
+
Comparison:
|
108
|
+
Digest::Blake3: 5698.2 i/s
|
109
|
+
Digest::SHA1: 612.2 i/s - 9.31x slower
|
110
|
+
Digest::MD5: 586.0 i/s - 9.72x slower
|
111
|
+
Digest::SHA256: 215.3 i/s - 26.47x slower
|
112
|
+
|
113
|
+
```
|
114
|
+
|
115
|
+
## Testing
|
116
|
+
|
117
|
+
First, make sure your development environment is setup:
|
118
|
+
|
119
|
+
```bash
|
120
|
+
$ bin/setup
|
121
|
+
```
|
122
|
+
|
123
|
+
To run the tests, execute:
|
124
|
+
|
125
|
+
```bash
|
126
|
+
$ bundle exec rake test
|
127
|
+
```
|
128
|
+
|
129
|
+
## Contributing
|
130
|
+
|
131
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Shopify/blake3-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/Shopify/blake3-ruby/blob/main/CODE_OF_CONDUCT.md).
|
132
|
+
|
133
|
+
## License
|
134
|
+
|
135
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
136
|
+
|
137
|
+
## Code of Conduct
|
138
|
+
|
139
|
+
Everyone interacting in the Blake3 project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/Shopify/blake3-ruby/blob/main/CODE_OF_CONDUCT.md).
|
data/lib/blake3-rb.rb
ADDED
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Tries to require the precompiled extension for the given Ruby version first
|
4
|
+
begin
|
5
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
6
|
+
require "digest/blake3/#{Regexp.last_match(1)}/blake3_ext"
|
7
|
+
rescue LoadError
|
8
|
+
require_relative "blake3/blake3_ext"
|
9
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blake3-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre10
|
5
|
+
platform: x86_64-linux
|
6
|
+
authors:
|
7
|
+
- Ian Ker-Seymer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Provides native bindings to the Blake3 hash function for Ruby.
|
14
|
+
email:
|
15
|
+
- ian.kerseymer@shopify.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- LICENSE.txt
|
21
|
+
- README.md
|
22
|
+
- lib/blake3-rb.rb
|
23
|
+
- lib/digest/blake3.rb
|
24
|
+
- lib/digest/blake3/3.0/blake3_ext.so
|
25
|
+
- lib/digest/blake3/3.1/blake3_ext.so
|
26
|
+
- lib/digest/blake3/3.2/blake3_ext.so
|
27
|
+
homepage: https://github.com/Shopify/blake3-ruby
|
28
|
+
licenses:
|
29
|
+
- MIT
|
30
|
+
metadata:
|
31
|
+
allowed_push_host: https://rubygems.org
|
32
|
+
homepage_uri: https://github.com/Shopify/blake3-ruby
|
33
|
+
source_code_uri: https://github.com/Shopify/blake3-ruby
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '3.0'
|
43
|
+
- - "<"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.3.dev
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 1.3.1
|
51
|
+
requirements: []
|
52
|
+
rubygems_version: 3.4.4
|
53
|
+
signing_key:
|
54
|
+
specification_version: 4
|
55
|
+
summary: Blake3 hash function bindings for Ruby.
|
56
|
+
test_files: []
|