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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1e5fca1a0e74f7d256340e2b2e12196ed97adc8ebc512697473d56c110fe682c
4
- data.tar.gz: 19d45327f812eede26a7a1432381e8c43d114ca0268ea1697b727db5c94c5ca9
3
+ metadata.gz: 154280692de39feb39b719344f5c47fd256decdb5bd71cf80cb54b87ef155bd3
4
+ data.tar.gz: 0aab5a7dc6e671530e0327bcad3bf9d4caae862fed9925bc9cdcc47a57eae68f
5
5
  SHA512:
6
- metadata.gz: e36e2adb4f23bf29d52a519e68e89dd5c947803399fd493bdab26c452e38142f11d7af03ef436f70c6f7a3c8881cee75b179167b5376556dfc91e4ab3f8ccc46
7
- data.tar.gz: 0e86593665d73afc22c91f6964df05f6134dc3b75b443932dde93ee38d296c692478b456a95110e042c4ff7dc54ccefb6cad84847dcd8a3e97d47736a6f25a6c
6
+ metadata.gz: 99c06212cd3c4908e1bf9c2a459e7f3cc851fbb38396256932787b9725b7aaad7873c7b3ac00bfde458bd2316f1e38e02e62734d0df43d1d1c6ca29c2905ea3c
7
+ data.tar.gz: c8680a7e9566fcd2d064560c46046f7bc97d1e3b257613c7396306912fac01dcb810f20604e87c4914c327cc1d0f66c3ae8fc952b40f75bec58f520da2f7c627
data/.document ADDED
@@ -0,0 +1,4 @@
1
+ LICENSE.txt
2
+ README.md
3
+ docs/
4
+ lib/
data/docs/random.rb ADDED
@@ -0,0 +1,10 @@
1
+ # This file is only for RDoc
2
+
3
+ # Random provides an interface to Ruby's pseudo-random number generator, or
4
+ # PRNG.
5
+ #
6
+ # See also Random::Formatter module that adds convenience methods to generate
7
+ # various forms of random data.
8
+
9
+ class Random
10
+ end
@@ -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 with Kernel#srand, which
205
- # can only affect the random bits. The sorted bits will still be based on
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
- VERSION = "0.3.0"
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.0
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-07 00:00:00.000000000 Z
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