paseto 0.4.0 → 0.4.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: b97852d5f74f9beb557884c9a46eb912fc3552400474dc7c35dbbbacedead44a
4
- data.tar.gz: e137a333a093be64c3ae218fa1884043bc61c8d3f585b8933ff777ab77a3269f
3
+ metadata.gz: 9871b9412181a110762916bec00e960682ed826f3c9627facddb1c1f236b4eba
4
+ data.tar.gz: 702b96ec10333a3f45d203d0aecc9330790292d1ddc03407bbd80447e1ad345e
5
5
  SHA512:
6
- metadata.gz: 28bdd43cb3e66b9566f9d71ffadfb6ff25b3ac47b569c51d6b2aa78af1e151e7e54f2f0508235da929e636897f62d88eee45a553675242a3d6f32976531fd197
7
- data.tar.gz: '098f57dd56ff3468b62d14123e7ac56de4928ca8d81a88b5cced5a42ca92e4069c87f2cf70f9924a32c8365fe366c4250b80da9c2490623af9afc5b39bc2cd43'
6
+ metadata.gz: 62c0fb8a1393f2065ecedfb76fb752cd2d0cc1fbe542dc45ef3812da37a7fafe60a237c13b42f666c9028bf46e729859ee6c2f524b54e9ab57c5ade277474403
7
+ data.tar.gz: 2f7bb535cedf9a058815a6550cb6e01897431f95466271e124faacb89611eb6ecf7d9e6ec5988adf8a5a2a6fd7ae2c7573994a71fdcd129927f07b67a08d63d7
@@ -7,6 +7,10 @@
7
7
  - Rubocop is the law :oncoming_police_car:
8
8
  - Update rake to fix vulnerability CVE-2020-8130
9
9
 
10
+ #### 0.4.1 (Mar 13, 2020)
11
+
12
+ - Add hex encoding support [<a href="https://github.com/mguymon/paseto.rb/pull/11">Pull #10</a> by <a href="https://github.com/shaicoleman">shaicoleman</a>]
13
+
10
14
  ### 0.3 (Dec 4, 2018)
11
15
 
12
16
  - Use rbnacl instead of rbnacl-libsodium [<a href="https://github.com/mguymon/paseto.rb/pull/6">Pull #3</a> by <a href="https://github.com/smaximov">smaximov</a>]
@@ -38,4 +38,12 @@ module Paseto
38
38
  # Remove the padding on the encode64
39
39
  Base64.urlsafe_encode64(bin).gsub(/=+$/, '')
40
40
  end
41
+
42
+ def self.decode_hex(str)
43
+ [str].pack('H*')
44
+ end
45
+
46
+ def self.encode_hex(bin)
47
+ bin.unpack('H*').first
48
+ end
41
49
  end
@@ -19,6 +19,10 @@ module Paseto
19
19
  new(Paseto.decode64(encoded_key))
20
20
  end
21
21
 
22
+ def self.decode_hex(encoded_key)
23
+ new(Paseto.decode_hex(encoded_key))
24
+ end
25
+
22
26
  def initialize(key)
23
27
  @key = key
24
28
  @aead = RbNaCl::AEAD::XChaCha20Poly1305IETF.new(key)
@@ -28,6 +32,10 @@ module Paseto
28
32
  Paseto.encode64(@key)
29
33
  end
30
34
 
35
+ def encode_hex
36
+ Paseto.encode_hex(@key)
37
+ end
38
+
31
39
  def encrypt(message, footer = EMPTY_FOOTER)
32
40
  # Make a nonce: A single-use value never repeated under the same key
33
41
  nonce = generate_nonce(message)
@@ -17,18 +17,22 @@ module Paseto
17
17
  end
18
18
  end
19
19
 
20
- # secret-key used for signing and verifing
20
+ # secret-key used for signing and verifying
21
21
  class SecretKey
22
22
  include Encoder
23
23
 
24
24
  def self.generate
25
- new(RbNaCl::SigningKey.generate)
25
+ new(RbNaCl::SigningKey.generate.to_bytes)
26
26
  end
27
27
 
28
28
  def self.decode64(encoded_key)
29
29
  new(Paseto.decode64(encoded_key))
30
30
  end
31
31
 
32
+ def self.decode_hex(encoded_key)
33
+ new(Paseto.decode_hex(encoded_key))
34
+ end
35
+
32
36
  def initialize(key)
33
37
  @key = key
34
38
  @nacl = RbNaCl::SigningKey.new(key)
@@ -53,6 +57,10 @@ module Paseto
53
57
  def encode64
54
58
  Paseto.encode64(@key)
55
59
  end
60
+
61
+ def encode_hex
62
+ Paseto.encode_hex(@key)
63
+ end
56
64
  end
57
65
 
58
66
  # public-key used for signing and verifing
@@ -63,6 +71,10 @@ module Paseto
63
71
  new(Paseto.decode64(encoded_key))
64
72
  end
65
73
 
74
+ def self.decode_hex(encoded_key)
75
+ new(Paseto.decode_hex(encoded_key))
76
+ end
77
+
66
78
  def initialize(key)
67
79
  @key = key
68
80
  @nacl = RbNaCl::VerifyKey.new(key)
@@ -72,6 +84,10 @@ module Paseto
72
84
  Paseto.encode64(@key)
73
85
  end
74
86
 
87
+ def encode_hex
88
+ Paseto.encode_hex(@key)
89
+ end
90
+
75
91
  def verify(token, footer = nil)
76
92
  footer ||= token.footer if token.is_a? Paseto::Token
77
93
  footer ||= EMPTY_FOOTER
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Paseto
4
- VERSION = '0.4.0'
4
+ VERSION = '0.4.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paseto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Guymon
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-07 00:00:00.000000000 Z
12
+ date: 2020-03-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rbnacl