crypto-toolbox 0.1.2 → 0.1.3
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 72dd22ea639f4e6096b3d4f666114445682c8347
|
4
|
+
data.tar.gz: 1054ec4b11d4b63394bd68baae0e961fa263e2e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bc4a46778a98981bd37764429d73cd55109c18c64724ff334534c84bea76ec452ac3eb9b35f8f4b49684989a04569bc83ab5efa1911db5257c531261c524c77
|
7
|
+
data.tar.gz: 9527fc3b387d2266e4c9a772b8d45976a46dbb4bd9b4d77e8b405d6feeb077265fab3da218f6fef5b9dd93b8dc81e13bf80aa6c347bd2f28a5cc9531cb896fc1
|
@@ -8,6 +8,7 @@ require 'crypto-toolbox/crypt_buffer/concerns/comparable.rb'
|
|
8
8
|
require 'crypto-toolbox/crypt_buffer/concerns/convertable.rb'
|
9
9
|
require 'crypto-toolbox/crypt_buffer/concerns/padding.rb'
|
10
10
|
require 'crypto-toolbox/crypt_buffer/concerns/pretty_print.rb'
|
11
|
+
require 'crypto-toolbox/crypt_buffer/concerns/random.rb'
|
11
12
|
require 'crypto-toolbox/crypt_buffer/concerns/xor.rb'
|
12
13
|
|
13
14
|
class CryptBuffer
|
@@ -19,6 +20,7 @@ class CryptBuffer
|
|
19
20
|
include CryptBufferConcern::Comparable
|
20
21
|
include CryptBufferConcern::Padding
|
21
22
|
include CryptBufferConcern::PrettyPrint
|
23
|
+
include CryptBufferConcern::Random
|
22
24
|
include CryptBufferConcern::Xor
|
23
25
|
|
24
26
|
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CryptBufferConcern
|
2
|
+
module Random
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend(ClassMethods)
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def random(n,seed: Time.now.to_i)
|
10
|
+
bytes = generate_bytes(n,seed)
|
11
|
+
CryptBuffer(bytes)
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
private
|
16
|
+
def generate_bytes(n,seed)
|
17
|
+
if n.nil? || n.zero?
|
18
|
+
[]
|
19
|
+
else
|
20
|
+
prng = ::Random.new(seed)
|
21
|
+
(1..n).map{|e| prng.rand 256 }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crypto-toolbox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dennis Sivia
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/crypto-toolbox/crypt_buffer/concerns/convertable.rb
|
59
59
|
- lib/crypto-toolbox/crypt_buffer/concerns/padding.rb
|
60
60
|
- lib/crypto-toolbox/crypt_buffer/concerns/pretty_print.rb
|
61
|
+
- lib/crypto-toolbox/crypt_buffer/concerns/random.rb
|
61
62
|
- lib/crypto-toolbox/crypt_buffer/concerns/xor.rb
|
62
63
|
- lib/crypto-toolbox/key_filter.rb
|
63
64
|
- lib/crypto-toolbox/spell_checker.rb
|