blake3-rb 0.1.0.pre10-x64-mingw32
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.rb +9 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7a349ad6318cc3919a7d5062b760a495ca3237be01b53a4bf358bb5dce97e6f3
|
4
|
+
data.tar.gz: c45297cf80aead11376520c42bf26d711eb77cb017d42c949cf4c346383790bc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b8223a8ce5d2ecfdc43db4cb286520c4eb9923a190370e84993c0f89620b7f1db942a462576809466beb5ce38daeb668cd55096fb26f32543505b3fcad28caa7
|
7
|
+
data.tar.gz: c314c669ff8b588b2c6bfcfda0028217666418fe25593d98db1001c39768001382677cc9cc92026bbe2391fa68378e325f1111a06934af652c71e9b5545935ef
|
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
|
@@ -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,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: blake3-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0.pre10
|
5
|
+
platform: x64-mingw32
|
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
|
+
homepage: https://github.com/Shopify/blake3-ruby
|
26
|
+
licenses:
|
27
|
+
- MIT
|
28
|
+
metadata:
|
29
|
+
allowed_push_host: https://rubygems.org
|
30
|
+
homepage_uri: https://github.com/Shopify/blake3-ruby
|
31
|
+
source_code_uri: https://github.com/Shopify/blake3-ruby
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.0'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 3.1.dev
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 1.3.1
|
49
|
+
requirements: []
|
50
|
+
rubygems_version: 3.4.4
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Blake3 hash function bindings for Ruby.
|
54
|
+
test_files: []
|