digest-blake2b 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +92 -0
- data/.gitignore +45 -0
- data/Gemfile +2 -0
- data/LICENSE +674 -0
- data/README.md +115 -0
- data/Rakefile +46 -0
- data/checksums/.keep +0 -0
- data/digest-blake2b.gemspec +49 -0
- data/ext/digest/blake2b_ext/blake2-config.h +72 -0
- data/ext/digest/blake2b_ext/blake2-impl.h +160 -0
- data/ext/digest/blake2b_ext/blake2.h +195 -0
- data/ext/digest/blake2b_ext/blake2b-load-sse2.h +68 -0
- data/ext/digest/blake2b_ext/blake2b-load-sse41.h +402 -0
- data/ext/digest/blake2b_ext/blake2b-ref.c +373 -0
- data/ext/digest/blake2b_ext/blake2b-round.h +157 -0
- data/ext/digest/blake2b_ext/extconf.rb +3 -0
- data/ext/digest/blake2b_ext/rbext.c +111 -0
- data/lib/digest/blake2b/key.rb +59 -0
- data/lib/digest/blake2b/version.rb +7 -0
- data/lib/digest/blake2b.rb +36 -0
- data/performance/performance_suite.rb +61 -0
- metadata +126 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'digest/blake2b_ext'
|
4
|
+
|
5
|
+
require 'digest/blake2b/key'
|
6
|
+
require 'digest/blake2b/version'
|
7
|
+
|
8
|
+
module Digest
|
9
|
+
class Blake2b
|
10
|
+
def self.hex(input, key = Blake2b::Key.none, out_len = 32)
|
11
|
+
check_if_valid!(input, key, out_len)
|
12
|
+
Blake2b.new(out_len, key).digest(input, :to_hex)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.bytes(input, key = Blake2b::Key.none, out_len = 32)
|
16
|
+
check_if_valid!(input, key, out_len)
|
17
|
+
Blake2b.new(out_len, key).digest(input, :to_bytes)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.check_if_valid!(input, key, out_len)
|
21
|
+
unless input.is_a?(String)
|
22
|
+
raise ArgumentError, 'input arg must be a String'
|
23
|
+
end
|
24
|
+
|
25
|
+
unless key.is_a?(Blake2b::Key)
|
26
|
+
raise ArgumentError, 'key arg must be a Blake2b::Key'
|
27
|
+
end
|
28
|
+
|
29
|
+
unless out_len.is_a?(Integer) && out_len.between?(1, 64)
|
30
|
+
raise ArgumentError, 'out_len arg must be an Integer between 1 and 64 inclusive'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private_class_method :check_if_valid!
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'digest'
|
2
|
+
require 'blake2'
|
3
|
+
require 'blake2b'
|
4
|
+
|
5
|
+
sample_string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec quis fermentum mauris, laoreet ultricies ipsum. Phasellus iaculis lacinia bibendum. Aenean eu lectus vitae nisi pellentesque condimentum. Cras imperdiet risus ut interdum dignissim. Nam ultricies vulputate varius. Morbi vehicula mi sit amet velit cursus, eu blandit dolor venenatis. Nunc vitae varius leo. Mauris metus nibh, ultrices nec odio in, viverra luctus purus. Duis luctus, dolor vel sodales semper, enim mauris sagittis dolor, at vehicula ligula ante eu lorem. Morbi porttitor lorem id turpis facilisis volutpat. Sed elementum porttitor sem, a ornare ligula. Integer tincidunt aliquam suscipit. Sed aliquam ligula id enim fringilla, vel ornare ante bibendum. Integer tincidunt, augue id condimentum fermentum, dolor urna molestie massa, sed congue enim quam eget arcu. Quisque feugiat purus sit amet porttitor tincidunt.
|
6
|
+
|
7
|
+
Fusce odio libero, lobortis quis ornare sit amet, dignissim sed erat. Praesent a iaculis ex. Ut libero amet."
|
8
|
+
|
9
|
+
run_count = 500_000
|
10
|
+
|
11
|
+
### MD5
|
12
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
13
|
+
run_count.times do |i|
|
14
|
+
Digest::MD5.hexdigest("#{i}#{sample_string}")
|
15
|
+
end
|
16
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
17
|
+
|
18
|
+
puts "MD5 result: #{ending - starting} seconds."
|
19
|
+
|
20
|
+
|
21
|
+
### SHA2
|
22
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
23
|
+
run_count.times do |i|
|
24
|
+
Digest::SHA2.hexdigest("#{i}#{sample_string}")
|
25
|
+
end
|
26
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
27
|
+
|
28
|
+
puts "SHA2 result: #{ending - starting} seconds."
|
29
|
+
|
30
|
+
|
31
|
+
### SHA512
|
32
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
33
|
+
run_count.times do |i|
|
34
|
+
Digest::SHA512.hexdigest("#{i}#{sample_string}")
|
35
|
+
end
|
36
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
37
|
+
|
38
|
+
puts "SHA512 result: #{ending - starting} seconds."
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
### BLAKE2s
|
43
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
44
|
+
unkeyed = Blake2::Key.none
|
45
|
+
run_count.times do |i|
|
46
|
+
Blake2.new(32, unkeyed).digest("#{i}#{sample_string}", :to_hex)
|
47
|
+
end
|
48
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
49
|
+
|
50
|
+
puts "BLAKE2s result: #{ending - starting} seconds."
|
51
|
+
|
52
|
+
|
53
|
+
### BLAKE2b
|
54
|
+
starting = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
55
|
+
unkeyed = Blake2b::Key.none
|
56
|
+
run_count.times do |i|
|
57
|
+
Blake2b.new(32, unkeyed).digest("#{i}#{sample_string}", :to_hex)
|
58
|
+
end
|
59
|
+
ending = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
60
|
+
|
61
|
+
puts "BLAKE2b result: #{ending - starting} seconds."
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: digest-blake2b
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Franck Verrot
|
8
|
+
- Mauricio Gomes
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2019-09-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake-compiler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0.9'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0.9'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.5'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.5'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '11.1'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '11.1'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: minitest
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '5.11'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '5.11'
|
70
|
+
description: BLAKE2b is a cryptographic hash function faster than MD5, SHA-1, SHA-2,
|
71
|
+
and SHA-3 for 64-bit systems.
|
72
|
+
email:
|
73
|
+
- mauricio@edge14.com
|
74
|
+
executables: []
|
75
|
+
extensions:
|
76
|
+
- ext/digest/blake2b_ext/extconf.rb
|
77
|
+
extra_rdoc_files: []
|
78
|
+
files:
|
79
|
+
- ".circleci/config.yml"
|
80
|
+
- ".gitignore"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- checksums/.keep
|
86
|
+
- digest-blake2b.gemspec
|
87
|
+
- ext/digest/blake2b_ext/blake2-config.h
|
88
|
+
- ext/digest/blake2b_ext/blake2-impl.h
|
89
|
+
- ext/digest/blake2b_ext/blake2.h
|
90
|
+
- ext/digest/blake2b_ext/blake2b-load-sse2.h
|
91
|
+
- ext/digest/blake2b_ext/blake2b-load-sse41.h
|
92
|
+
- ext/digest/blake2b_ext/blake2b-ref.c
|
93
|
+
- ext/digest/blake2b_ext/blake2b-round.h
|
94
|
+
- ext/digest/blake2b_ext/extconf.rb
|
95
|
+
- ext/digest/blake2b_ext/rbext.c
|
96
|
+
- lib/digest/blake2b.rb
|
97
|
+
- lib/digest/blake2b/key.rb
|
98
|
+
- lib/digest/blake2b/version.rb
|
99
|
+
- performance/performance_suite.rb
|
100
|
+
homepage: https://github.com/kotovalexarian/digest-blake2b.rb
|
101
|
+
licenses:
|
102
|
+
- GPL-3.0
|
103
|
+
metadata:
|
104
|
+
homepage_uri: https://github.com/kotovalexarian/digest-blake2b.rb
|
105
|
+
source_code_uri: https://github.com/kotovalexarian/digest-blake2b.rb
|
106
|
+
bug_tracker_uri: https://github.com/kotovalexarian/digest-blake2b.rb/issues
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
require_paths:
|
110
|
+
- lib
|
111
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
112
|
+
requirements:
|
113
|
+
- - "~>"
|
114
|
+
- !ruby/object:Gem::Version
|
115
|
+
version: '2.1'
|
116
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '0'
|
121
|
+
requirements: []
|
122
|
+
rubygems_version: 3.0.3
|
123
|
+
signing_key:
|
124
|
+
specification_version: 4
|
125
|
+
summary: The BLAKE2b cryptographic hash function.
|
126
|
+
test_files: []
|