securerandom 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.document +4 -0
- data/docs/random.rb +10 -0
- data/lib/random/formatter.rb +5 -3
- data/lib/securerandom.rb +12 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 154280692de39feb39b719344f5c47fd256decdb5bd71cf80cb54b87ef155bd3
|
4
|
+
data.tar.gz: 0aab5a7dc6e671530e0327bcad3bf9d4caae862fed9925bc9cdcc47a57eae68f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 99c06212cd3c4908e1bf9c2a459e7f3cc851fbb38396256932787b9725b7aaad7873c7b3ac00bfde458bd2316f1e38e02e62734d0df43d1d1c6ca29c2905ea3c
|
7
|
+
data.tar.gz: c8680a7e9566fcd2d064560c46046f7bc97d1e3b257613c7396306912fac01dcb810f20604e87c4914c327cc1d0f66c3ae8fc952b40f75bec58f520da2f7c627
|
data/.document
ADDED
data/docs/random.rb
ADDED
data/lib/random/formatter.rb
CHANGED
@@ -201,9 +201,8 @@ module Random::Formatter
|
|
201
201
|
#
|
202
202
|
# The result contains 74 random bits (9.25 random bytes).
|
203
203
|
#
|
204
|
-
# Note that this method cannot be made reproducable
|
205
|
-
#
|
206
|
-
# Process.clock_gettime.
|
204
|
+
# Note that this method cannot be made reproducable because its output
|
205
|
+
# includes not only random bits but also timestamp.
|
207
206
|
#
|
208
207
|
# See draft-ietf-uuidrev-rfc4122bis[https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/]
|
209
208
|
# for details of UUIDv7.
|
@@ -293,6 +292,7 @@ module Random::Formatter
|
|
293
292
|
end
|
294
293
|
end
|
295
294
|
|
295
|
+
# Internal interface to Random; Generate random data _n_ bytes.
|
296
296
|
private def gen_random(n)
|
297
297
|
self.bytes(n)
|
298
298
|
end
|
@@ -340,7 +340,9 @@ module Random::Formatter
|
|
340
340
|
result
|
341
341
|
end
|
342
342
|
|
343
|
+
# The default character list for #alphanumeric.
|
343
344
|
ALPHANUMERIC = [*'A'..'Z', *'a'..'z', *'0'..'9']
|
345
|
+
|
344
346
|
# Generate a random alphanumeric string.
|
345
347
|
#
|
346
348
|
# The argument _n_ specifies the length, in characters, of the alphanumeric
|
data/lib/securerandom.rb
CHANGED
@@ -40,19 +40,27 @@ require 'random/formatter'
|
|
40
40
|
|
41
41
|
module SecureRandom
|
42
42
|
|
43
|
-
|
43
|
+
# The version
|
44
|
+
VERSION = "0.3.1"
|
44
45
|
|
45
46
|
class << self
|
47
|
+
# Returns a random binary string containing +size+ bytes.
|
48
|
+
#
|
49
|
+
# See Random.bytes
|
46
50
|
def bytes(n)
|
47
51
|
return gen_random(n)
|
48
52
|
end
|
49
53
|
|
50
54
|
private
|
51
55
|
|
56
|
+
# :stopdoc:
|
57
|
+
|
58
|
+
# Implementation using OpenSSL
|
52
59
|
def gen_random_openssl(n)
|
53
60
|
return OpenSSL::Random.random_bytes(n)
|
54
61
|
end
|
55
62
|
|
63
|
+
# Implementation using system random device
|
56
64
|
def gen_random_urandom(n)
|
57
65
|
ret = Random.urandom(n)
|
58
66
|
unless ret
|
@@ -78,6 +86,9 @@ module SecureRandom
|
|
78
86
|
end
|
79
87
|
end
|
80
88
|
|
89
|
+
# :startdoc:
|
90
|
+
|
91
|
+
# Generate random data bytes for Random::Formatter
|
81
92
|
public :gen_random
|
82
93
|
end
|
83
94
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: securerandom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tanaka Akira
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Interface for secure random number generator.
|
14
14
|
email:
|
@@ -17,6 +17,7 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".document"
|
20
21
|
- ".github/dependabot.yml"
|
21
22
|
- ".github/workflows/test.yml"
|
22
23
|
- ".gitignore"
|
@@ -26,6 +27,7 @@ files:
|
|
26
27
|
- Rakefile
|
27
28
|
- bin/console
|
28
29
|
- bin/setup
|
30
|
+
- docs/random.rb
|
29
31
|
- lib/random/formatter.rb
|
30
32
|
- lib/securerandom.rb
|
31
33
|
- rakelib/epoch.rake
|