digest-base32 0.0.1 → 0.0.2

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: fa377043eb6395c1c5e4a291ead93e4fd4b6fc8d47f27e170062eea1681cfd34
4
- data.tar.gz: 6c26617c5aac5d78856c95da27df1fb83fd5ae99c9fdebd801a1be2959c8b074
3
+ metadata.gz: 7fca59661b4ef22a81c0027994c420a5acdf00989a47b23e6206012f198c6b76
4
+ data.tar.gz: 83e51fa62a12b3370660cdb717d1771ee8510e9ac2df7d920c54ae61cc74dfa8
5
5
  SHA512:
6
- metadata.gz: 41eced816a3b48b60e3ebdb51d91d55cf34dd16fff7cba2eaffe5fb297f15126fac25849036f9b75614cc15911eaee443807155633167cc7c3e20fef766f3e3d
7
- data.tar.gz: fffb14ed6166fa9b0a60e2c2ebd7a84de74474e32e69e50a67dba434794f3ec7fffe0806ac45f191566d6cdad3977139b0abb0587ed01e6388707e3816944e1d
6
+ metadata.gz: f1f205a6d4158e0adf04774dfca5ec1229660b37d62630db4a6154952dd4b321a658fe537f58650b29e5be89d6b59314bb4094d09b3e10302987836ba830586d
7
+ data.tar.gz: fe261bb240202c120e6f9466dc5f578323f52af14402c21da131ff238037fe7434cefd1a44c1e9c2c7677fce67bc3613f9f9b1587eb3d693c098a3b97f046654
@@ -40,7 +40,7 @@ Gem::Specification.new do |spec|
40
40
 
41
41
  spec.executables = spec.files.grep %r{^exe/}, &File.method(:basename)
42
42
 
43
- spec.extensions << 'ext/digest/base32/extconf.rb'
43
+ spec.extensions << 'ext/digest/base32_ext/extconf.rb'
44
44
 
45
45
  spec.add_development_dependency 'base32', '~> 0.3.2'
46
46
  spec.add_development_dependency 'bundler', '~> 2.1'
File without changes
File without changes
@@ -53,7 +53,7 @@ digest_base32_decode(int argc, VALUE *argv, VALUE self)
53
53
  }
54
54
 
55
55
  void
56
- Init_base32() {
56
+ Init_base32_ext() {
57
57
  mDigest = rb_define_module("Digest");
58
58
  mDigest_cBase32 = rb_define_class_under(mDigest, "Base32", rb_cObject);
59
59
 
@@ -6,4 +6,4 @@ dir_config('digest/base32')
6
6
 
7
7
  raise 'Could not find base32.h' unless find_header 'base32.h', __dir__
8
8
 
9
- create_makefile('digest/base32')
9
+ create_makefile('digest/base32_ext')
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'digest/base32_ext'
4
+
5
+ require 'digest/base32/version'
6
+
7
+ require 'securerandom'
8
+
9
+ module Digest
10
+ class Base32
11
+ CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'
12
+
13
+ def self.random(length: 16, padding: true)
14
+ unless length.is_a? Integer
15
+ raise TypeError, "Expected #{Integer}, got #{length.class}"
16
+ end
17
+
18
+ unless [true, false].include? padding
19
+ raise TypeError, "Expected bool, got #{padding.class}"
20
+ end
21
+
22
+ random = +''
23
+ SecureRandom.random_bytes(length).each_byte do |b|
24
+ random << CHARS[b % 32]
25
+ end
26
+ padding ? random.ljust((length / 8.0).ceil * 8, '=') : random
27
+ end
28
+ end
29
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Digest
4
4
  class Base32
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digest-base32
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Cook
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-20 00:00:00.000000000 Z
11
+ date: 2020-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base32
@@ -126,16 +126,17 @@ description: Ruby native extension for base32 encoding and decoding.
126
126
  email:
127
127
  executables: []
128
128
  extensions:
129
- - ext/digest/base32/extconf.rb
129
+ - ext/digest/base32_ext/extconf.rb
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - LICENSE
133
133
  - README.md
134
134
  - digest-base32.gemspec
135
- - ext/digest/base32/base32.c
136
- - ext/digest/base32/base32.h
137
- - ext/digest/base32/digest-base32.c
138
- - ext/digest/base32/extconf.rb
135
+ - ext/digest/base32_ext/base32.c
136
+ - ext/digest/base32_ext/base32.h
137
+ - ext/digest/base32_ext/digest-base32.c
138
+ - ext/digest/base32_ext/extconf.rb
139
+ - lib/digest/base32.rb
139
140
  - lib/digest/base32/version.rb
140
141
  homepage: https://github.com/ydakuka/digest-base32
141
142
  licenses:
@@ -159,7 +160,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
159
160
  - !ruby/object:Gem::Version
160
161
  version: '0'
161
162
  requirements: []
162
- rubygems_version: 3.0.3
163
+ rubyforge_project:
164
+ rubygems_version: 2.7.7
163
165
  signing_key:
164
166
  specification_version: 4
165
167
  summary: Base32 Ruby C Extension