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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2588af68ad8e413e470a5d21cbc79689d04c5db3c9f1de361f30f5257b248c3
4
- data.tar.gz: 0006dc49d9e85996b98d29a683f3472a379bc14dc63545a2888e06f98a3268ac
3
+ metadata.gz: 13a45473ead2b57671c5cca9f88eea4d45250e5dc20979bee5ed8809b882be51
4
+ data.tar.gz: 73caf787eba77f51d32dd9ab01c2d7ade5d3dedcd4c41ea989d16de935a97d3b
5
5
  SHA512:
6
- metadata.gz: 447cf77421c0569d4732c4d128bdbd67c10e4faae0a7848ea0495e2d91096f131a0befb645f844b3354b8e4da78f86792ee3a25a3e4a2dc03234068b89384644
7
- data.tar.gz: 262574457d683e4627b16ddac3af7522ee79bf93a93b2e1948318c0af5e2c8314c81c7f73046911a235f03fda9c647e119c1d0872d3424bf783a7c407c58cb7d
6
+ metadata.gz: 862fc3bf9c51e9892532abb4ae7e952ceee55c7731b0448ed06e178568401f054b91e125927e8e122975201117399270578af043842aae252ef5593c313c81e6
7
+ data.tar.gz: 8dd8c150730470bc48625d306210b42074978a691d808966538d5fd64649c452a1782a2520117f7dfd326698125fd997c36c9cc8d1f44e11a0b254f086097d70
data/.gitignore CHANGED
@@ -8,6 +8,9 @@
8
8
  /tmp/
9
9
  /target/
10
10
  /vendor/
11
+ *.bundle
12
+ Cargo.lock
13
+ Gemfile.lock
11
14
 
12
15
  # rspec failure tracking
13
16
  .rspec_status
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.0"
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.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ba0511b7f4f7d9cb1ef7b8dfda5293af6c1071578d65c8a05aa7d11c1985f08c"
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
@@ -1,5 +1,5 @@
1
1
  [package]
2
- name = "blake3"
2
+ name = "blake3native"
3
3
  version = "0.1.0"
4
4
  authors = ["Hajime Yamaguchi <gen.yamaguchi0@gmail.com>"]
5
5
  edition = "2018"
@@ -11,4 +11,3 @@ crate-type = ["cdylib"]
11
11
  blake3 = "0.1.1"
12
12
  helix = "0.7.5"
13
13
  hex = "0.3"
14
-
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
- TODO: Write usage instructions here
29
+ ```ruby
30
+ require "blake3"
31
+
32
+ Blake3.hexdigest("hoge")
33
+ # => 77412ee5089c51bcf6568c621aa3a83081a6477b576ff19bfb31e9d657acd91a
34
+ ```
26
35
 
27
36
  ## Development
28
37
 
@@ -1,18 +1,48 @@
1
1
  require 'helix_runtime'
2
2
 
3
- require 'blake3/native'
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
- hex = plain.unpack1("H*")
11
- Blake3Internal.new.from_hex(hex)
10
+ Hasher.hexdigest(plain)
12
11
  end
13
12
 
14
13
  def digest(plain)
15
- hex = hexdigest(plain)
16
- [hex].pack("H*")
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
@@ -1,3 +1,3 @@
1
1
  module Blake3
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/src/lib.rs CHANGED
@@ -2,27 +2,25 @@
2
2
  extern crate helix;
3
3
 
4
4
  ruby! {
5
- class Blake3Internal {
5
+ class Blake3Hasher {
6
6
  struct {
7
+ hasher: blake3::Hasher,
7
8
  }
8
9
 
9
10
  def initialize(helix) {
10
- Blake3Internal{helix}
11
+ Blake3Hasher {
12
+ helix,
13
+ hasher: blake3::Hasher::new(),
14
+ }
11
15
  }
12
16
 
13
- def from_hex(&self, hex: std::string::String) -> std::string::String {
17
+ def update(&mut self, hex: std::string::String) {
14
18
  let decoded = hex::decode(hex).expect("Decoding failed");
15
- let hash = blake3::hash(&decoded[..]);
16
- format!("{}", hash.to_hex())
19
+ self.hasher.update(&decoded[..]);
17
20
  }
18
- }
19
- }
20
21
 
21
- #[test]
22
- fn test() {
23
- let hex = "686f6765";
24
- let decoded = hex::decode(hex).expect("Decoding failed");
25
- let hash = blake3::hash(&decoded[..]);
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.0
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-17 00:00:00.000000000 Z
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
@@ -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
Binary file