securerandom 0.3.1 → 0.3.2

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: 154280692de39feb39b719344f5c47fd256decdb5bd71cf80cb54b87ef155bd3
4
- data.tar.gz: 0aab5a7dc6e671530e0327bcad3bf9d4caae862fed9925bc9cdcc47a57eae68f
3
+ metadata.gz: 6f14853630e9280f98e432e1da48fd1eb894a7376c4e3678dc97639e28929c3d
4
+ data.tar.gz: 79846163a70d7b0198271a61ce63a7320c9a141dd59d0912a91e9a5259353999
5
5
  SHA512:
6
- metadata.gz: 99c06212cd3c4908e1bf9c2a459e7f3cc851fbb38396256932787b9725b7aaad7873c7b3ac00bfde458bd2316f1e38e02e62734d0df43d1d1c6ca29c2905ea3c
7
- data.tar.gz: c8680a7e9566fcd2d064560c46046f7bc97d1e3b257613c7396306912fac01dcb810f20604e87c4914c327cc1d0f66c3ae8fc952b40f75bec58f520da2f7c627
6
+ metadata.gz: 7d448c439592c67f07e543c855fa4c06e6da72ce84d31ade33ea97d76d5ee90952b575c938a34bf8e11453353920582d0d5311cf9212b6ba7397fa3d038bc2e5
7
+ data.tar.gz: c3080d88c1a11a88ca3a28ddc6e173ab5afbf6027d60c353263ed9f78b8982a55dcc15c4a88cc3f2a44ba6e8a5933d7283af91b2f38965f67ebd68e636d78922
@@ -4,10 +4,10 @@ Redistribution and use in source and binary forms, with or without
4
4
  modification, are permitted provided that the following conditions
5
5
  are met:
6
6
  1. Redistributions of source code must retain the above copyright
7
- notice, this list of conditions and the following disclaimer.
7
+ notice, this list of conditions and the following disclaimer.
8
8
  2. Redistributions in binary form must reproduce the above copyright
9
- notice, this list of conditions and the following disclaimer in the
10
- documentation and/or other materials provided with the distribution.
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
11
 
12
12
  THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
13
  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a. place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b. use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c. give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d. make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a. distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b. accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c. give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d. make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
@@ -165,13 +165,13 @@ module Random::Formatter
165
165
  #
166
166
  # The result contains 122 random bits (15.25 random bytes).
167
167
  #
168
- # See RFC4122[https://datatracker.ietf.org/doc/html/rfc4122] for details of UUID.
168
+ # See RFC9562[https://www.rfc-editor.org/rfc/rfc9562] for details of UUIDv4.
169
169
  #
170
170
  def uuid
171
- ary = random_bytes(16).unpack("NnnnnN")
172
- ary[2] = (ary[2] & 0x0fff) | 0x4000
173
- ary[3] = (ary[3] & 0x3fff) | 0x8000
174
- "%08x-%04x-%04x-%04x-%04x%08x" % ary
171
+ ary = random_bytes(16)
172
+ ary.setbyte(6, (ary.getbyte(6) & 0x0f) | 0x40)
173
+ ary.setbyte(8, (ary.getbyte(8) & 0x3f) | 0x80)
174
+ ary.unpack("H8H4H4H4H12").join(?-)
175
175
  end
176
176
 
177
177
  alias uuid_v4 uuid
@@ -201,11 +201,10 @@ 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 because its output
204
+ # Note that this method cannot be made reproducible because its output
205
205
  # includes not only random bits but also timestamp.
206
206
  #
207
- # See draft-ietf-uuidrev-rfc4122bis[https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis/]
208
- # for details of UUIDv7.
207
+ # See RFC9562[https://www.rfc-editor.org/rfc/rfc9562] for details of UUIDv7.
209
208
  #
210
209
  # ==== Monotonicity
211
210
  #
@@ -242,7 +241,7 @@ module Random::Formatter
242
241
  #
243
242
  # Counters and other mechanisms for stronger guarantees of monotonicity are
244
243
  # not implemented. Applications with stricter requirements should follow
245
- # {Section 6.2}[https://www.ietf.org/archive/id/draft-ietf-uuidrev-rfc4122bis-07.html#monotonicity_counters]
244
+ # {Section 6.2}[https://www.rfc-editor.org/rfc/rfc9562.html#name-monotonicity-and-counters]
246
245
  # of the specification.
247
246
  #
248
247
  def uuid_v7(extra_timestamp_bits: 0)
data/lib/securerandom.rb CHANGED
@@ -41,7 +41,7 @@ require 'random/formatter'
41
41
  module SecureRandom
42
42
 
43
43
  # The version
44
- VERSION = "0.3.1"
44
+ VERSION = "0.3.2"
45
45
 
46
46
  class << self
47
47
  # Returns a random binary string containing +size+ bytes.
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanaka Akira
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-12-16 00:00:00.000000000 Z
11
+ date: 2024-11-11 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Interface for secure random number generator.
14
14
  email:
@@ -17,21 +17,11 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".document"
21
- - ".github/dependabot.yml"
22
- - ".github/workflows/test.yml"
23
- - ".gitignore"
24
- - Gemfile
25
- - LICENSE.txt
20
+ - BSDL
21
+ - COPYING
26
22
  - README.md
27
- - Rakefile
28
- - bin/console
29
- - bin/setup
30
- - docs/random.rb
31
23
  - lib/random/formatter.rb
32
24
  - lib/securerandom.rb
33
- - rakelib/epoch.rake
34
- - securerandom.gemspec
35
25
  homepage: https://github.com/ruby/securerandom
36
26
  licenses:
37
27
  - Ruby
@@ -39,7 +29,7 @@ licenses:
39
29
  metadata:
40
30
  homepage_uri: https://github.com/ruby/securerandom
41
31
  source_code_uri: https://github.com/ruby/securerandom
42
- post_install_message:
32
+ post_install_message:
43
33
  rdoc_options: []
44
34
  require_paths:
45
35
  - lib
@@ -54,8 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
54
44
  - !ruby/object:Gem::Version
55
45
  version: '0'
56
46
  requirements: []
57
- rubygems_version: 3.5.0.dev
58
- signing_key:
47
+ rubygems_version: 3.5.11
48
+ signing_key:
59
49
  specification_version: 4
60
50
  summary: Interface for secure random number generator.
61
51
  test_files: []
data/.document DELETED
@@ -1,4 +0,0 @@
1
- LICENSE.txt
2
- README.md
3
- docs/
4
- lib/
@@ -1,6 +0,0 @@
1
- version: 2
2
- updates:
3
- - package-ecosystem: 'github-actions'
4
- directory: '/'
5
- schedule:
6
- interval: 'weekly'
@@ -1,29 +0,0 @@
1
- name: test
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- ruby-versions:
7
- uses: ruby/actions/.github/workflows/ruby_versions.yml@master
8
- with:
9
- engine: cruby
10
- min_version: 2.6
11
-
12
- test:
13
- needs: ruby-versions
14
- name: build (${{ matrix.ruby }} / ${{ matrix.os }})
15
- strategy:
16
- matrix:
17
- ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
18
- os: [ ubuntu-latest, macos-latest, windows-latest ]
19
- runs-on: ${{ matrix.os }}
20
- steps:
21
- - uses: actions/checkout@v4
22
- - name: Set up Ruby
23
- uses: ruby/setup-ruby@v1
24
- with:
25
- ruby-version: ${{ matrix.ruby }}
26
- - name: Install dependencies
27
- run: bundle install
28
- - name: Run test
29
- run: rake test
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rake"
4
- gem "test-unit"
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
3
-
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/test_*.rb"]
8
- end
9
-
10
- task :default => :test
data/bin/console DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "securerandom"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
data/docs/random.rb DELETED
@@ -1,10 +0,0 @@
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
data/rakelib/epoch.rake DELETED
@@ -1,5 +0,0 @@
1
- task "build" => "date_epoch"
2
-
3
- task "date_epoch" do
4
- ENV["SOURCE_DATE_EPOCH"] = IO.popen(%W[git -C #{__dir__} log -1 --format=%ct], &:read).chomp
5
- end
data/securerandom.gemspec DELETED
@@ -1,29 +0,0 @@
1
- name = File.basename(__FILE__, ".gemspec")
2
- version = ["lib", Array.new(name.count("-")+1).join("/")].find do |dir|
3
- break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
4
- /^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
5
- end rescue nil
6
- end
7
-
8
- Gem::Specification.new do |spec|
9
- spec.name = name
10
- spec.version = version
11
- spec.authors = ["Tanaka Akira"]
12
- spec.email = ["akr@fsij.org"]
13
-
14
- spec.summary = %q{Interface for secure random number generator.}
15
- spec.description = %q{Interface for secure random number generator.}
16
- spec.homepage = "https://github.com/ruby/securerandom"
17
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
18
- spec.licenses = ["Ruby", "BSD-2-Clause"]
19
-
20
- spec.metadata["homepage_uri"] = spec.homepage
21
- spec.metadata["source_code_uri"] = spec.homepage
22
-
23
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
24
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
- end
26
- spec.bindir = "exe"
27
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
- spec.require_paths = ["lib"]
29
- end