blake3 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Cargo.lock +11 -11
- data/Cargo.toml +1 -2
- data/README.md +10 -1
- data/lib/blake3.rb +36 -6
- data/lib/blake3/version.rb +1 -1
- data/src/lib.rs +13 -15
- metadata +2 -4
- data/Gemfile.lock +0 -42
- data/lib/blake3/native.bundle +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 13a45473ead2b57671c5cca9f88eea4d45250e5dc20979bee5ed8809b882be51
|
4
|
+
data.tar.gz: 73caf787eba77f51d32dd9ab01c2d7ade5d3dedcd4c41ea989d16de935a97d3b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 862fc3bf9c51e9892532abb4ae7e952ceee55c7731b0448ed06e178568401f054b91e125927e8e122975201117399270578af043842aae252ef5593c313c81e6
|
7
|
+
data.tar.gz: 8dd8c150730470bc48625d306210b42074978a691d808966538d5fd64649c452a1782a2520117f7dfd326698125fd997c36c9cc8d1f44e11a0b254f086097d70
|
data/.gitignore
CHANGED
data/Cargo.lock
CHANGED
@@ -12,16 +12,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
12
12
|
|
13
13
|
[[package]]
|
14
14
|
name = "blake3"
|
15
|
-
version = "0.1.
|
16
|
-
dependencies = [
|
17
|
-
"blake3 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
18
|
-
"helix 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
19
|
-
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
20
|
-
]
|
21
|
-
|
22
|
-
[[package]]
|
23
|
-
name = "blake3"
|
24
|
-
version = "0.1.1"
|
15
|
+
version = "0.1.2"
|
25
16
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
26
17
|
dependencies = [
|
27
18
|
"arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
@@ -31,6 +22,15 @@ dependencies = [
|
|
31
22
|
"constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
32
23
|
]
|
33
24
|
|
25
|
+
[[package]]
|
26
|
+
name = "blake3native"
|
27
|
+
version = "0.1.0"
|
28
|
+
dependencies = [
|
29
|
+
"blake3 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
30
|
+
"helix 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
31
|
+
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
32
|
+
]
|
33
|
+
|
34
34
|
[[package]]
|
35
35
|
name = "cc"
|
36
36
|
version = "1.0.50"
|
@@ -82,7 +82,7 @@ dependencies = [
|
|
82
82
|
[metadata]
|
83
83
|
"checksum arrayref 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" = "0d382e583f07208808f6b1249e60848879ba3543f57c32277bf52d69c2f0f0ee"
|
84
84
|
"checksum arrayvec 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "cff77d8686867eceff3105329d4698d96c2391c176d5d03adc90c7389162b5b8"
|
85
|
-
"checksum blake3 0.1.
|
85
|
+
"checksum blake3 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "67c992939e50f9ef6207ca51dfe23c527baa83b7b825ef0f7d71e99b6d35128e"
|
86
86
|
"checksum cc 1.0.50 (registry+https://github.com/rust-lang/crates.io-index)" = "95e28fa049fda1c330bcf9d723be7663a899c4679724b34c81e9f5a326aab8cd"
|
87
87
|
"checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822"
|
88
88
|
"checksum constant_time_eq 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "245097e9a4535ee1e3e3931fcfcd55a796a44c643e8596ff6566d68f09b87bbc"
|
data/Cargo.toml
CHANGED
data/README.md
CHANGED
@@ -6,6 +6,10 @@ TODO: Delete this and the text above, and describe your gem
|
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
9
|
+
This library contains native extension made by Rust.
|
10
|
+
First, you must install Rust and Cargo.
|
11
|
+
see https://doc.rust-lang.org/cargo/getting-started/installation.html
|
12
|
+
|
9
13
|
Add this line to your application's Gemfile:
|
10
14
|
|
11
15
|
```ruby
|
@@ -22,7 +26,12 @@ Or install it yourself as:
|
|
22
26
|
|
23
27
|
## Usage
|
24
28
|
|
25
|
-
|
29
|
+
```ruby
|
30
|
+
require "blake3"
|
31
|
+
|
32
|
+
Blake3.hexdigest("hoge")
|
33
|
+
# => 77412ee5089c51bcf6568c621aa3a83081a6477b576ff19bfb31e9d657acd91a
|
34
|
+
```
|
26
35
|
|
27
36
|
## Development
|
28
37
|
|
data/lib/blake3.rb
CHANGED
@@ -1,18 +1,48 @@
|
|
1
1
|
require 'helix_runtime'
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'blake3native/native'
|
4
4
|
require "blake3/version"
|
5
5
|
|
6
6
|
module Blake3
|
7
7
|
module_function
|
8
|
-
|
8
|
+
|
9
9
|
def hexdigest(plain)
|
10
|
-
|
11
|
-
Blake3Internal.new.from_hex(hex)
|
10
|
+
Hasher.hexdigest(plain)
|
12
11
|
end
|
13
12
|
|
14
13
|
def digest(plain)
|
15
|
-
|
16
|
-
|
14
|
+
Hasher.digest(plain)
|
15
|
+
end
|
16
|
+
|
17
|
+
class Hasher
|
18
|
+
def initialize
|
19
|
+
@hasher = Blake3Hasher.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def update(plain)
|
23
|
+
hex = plain.unpack1("H*")
|
24
|
+
@hasher.update(hex)
|
25
|
+
self
|
26
|
+
end
|
27
|
+
|
28
|
+
def finalize
|
29
|
+
@hasher.finalize
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.digest(plain)
|
33
|
+
new.update(plain).digest
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.hexdigest(plain)
|
37
|
+
new.update(plain).hexdigest
|
38
|
+
end
|
39
|
+
|
40
|
+
def digest
|
41
|
+
[hexdigest].pack("H*")
|
42
|
+
end
|
43
|
+
|
44
|
+
def hexdigest
|
45
|
+
finalize
|
46
|
+
end
|
17
47
|
end
|
18
48
|
end
|
data/lib/blake3/version.rb
CHANGED
data/src/lib.rs
CHANGED
@@ -2,27 +2,25 @@
|
|
2
2
|
extern crate helix;
|
3
3
|
|
4
4
|
ruby! {
|
5
|
-
class
|
5
|
+
class Blake3Hasher {
|
6
6
|
struct {
|
7
|
+
hasher: blake3::Hasher,
|
7
8
|
}
|
8
9
|
|
9
10
|
def initialize(helix) {
|
10
|
-
|
11
|
+
Blake3Hasher {
|
12
|
+
helix,
|
13
|
+
hasher: blake3::Hasher::new(),
|
14
|
+
}
|
11
15
|
}
|
12
16
|
|
13
|
-
def
|
17
|
+
def update(&mut self, hex: std::string::String) {
|
14
18
|
let decoded = hex::decode(hex).expect("Decoding failed");
|
15
|
-
|
16
|
-
format!("{}", hash.to_hex())
|
19
|
+
self.hasher.update(&decoded[..]);
|
17
20
|
}
|
18
|
-
}
|
19
|
-
}
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
let hexdigest = format!("{}", hash.to_hex());
|
27
|
-
assert_eq!(hexdigest, "77412ee5089c51bcf6568c621aa3a83081a6477b576ff19bfb31e9d657acd91a");
|
28
|
-
}
|
22
|
+
def finalize(&mut self) -> std::string::String {
|
23
|
+
format!("{}", self.hasher.finalize().to_hex())
|
24
|
+
}
|
25
|
+
}
|
26
|
+
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blake3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hajime Yamaguchi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,7 +80,6 @@ files:
|
|
80
80
|
- Cargo.lock
|
81
81
|
- Cargo.toml
|
82
82
|
- Gemfile
|
83
|
-
- Gemfile.lock
|
84
83
|
- LICENSE
|
85
84
|
- LICENSE.txt
|
86
85
|
- README.md
|
@@ -89,7 +88,6 @@ files:
|
|
89
88
|
- bin/setup
|
90
89
|
- blake3.gemspec
|
91
90
|
- lib/blake3.rb
|
92
|
-
- lib/blake3/native.bundle
|
93
91
|
- lib/blake3/version.rb
|
94
92
|
- src/lib.rs
|
95
93
|
homepage: https://github.com/Yamaguchi/blake3rb
|
data/Gemfile.lock
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
blake3 (0.1.0)
|
5
|
-
helix_runtime (= 0.7.5)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
diff-lcs (1.3)
|
11
|
-
helix_runtime (0.7.5)
|
12
|
-
rake (>= 10.0)
|
13
|
-
thor (>= 0.19.4, < 2.0)
|
14
|
-
tomlrb (~> 1.2.4)
|
15
|
-
rake (10.5.0)
|
16
|
-
rspec (3.9.0)
|
17
|
-
rspec-core (~> 3.9.0)
|
18
|
-
rspec-expectations (~> 3.9.0)
|
19
|
-
rspec-mocks (~> 3.9.0)
|
20
|
-
rspec-core (3.9.1)
|
21
|
-
rspec-support (~> 3.9.1)
|
22
|
-
rspec-expectations (3.9.0)
|
23
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
24
|
-
rspec-support (~> 3.9.0)
|
25
|
-
rspec-mocks (3.9.1)
|
26
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
27
|
-
rspec-support (~> 3.9.0)
|
28
|
-
rspec-support (3.9.2)
|
29
|
-
thor (1.0.1)
|
30
|
-
tomlrb (1.2.9)
|
31
|
-
|
32
|
-
PLATFORMS
|
33
|
-
ruby
|
34
|
-
|
35
|
-
DEPENDENCIES
|
36
|
-
blake3!
|
37
|
-
bundler (~> 1.17)
|
38
|
-
rake (~> 10.0)
|
39
|
-
rspec (~> 3.0)
|
40
|
-
|
41
|
-
BUNDLED WITH
|
42
|
-
1.17.2
|
data/lib/blake3/native.bundle
DELETED
Binary file
|