lazy_rsa 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/lazy_rsa.rb +7 -2
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21e9a09c2b446c925d4ac119589f7f24b549f7bc662863dd5d64c4c41812e336
4
- data.tar.gz: 9bdc9ceda55df07759aba32d77a8f92c0328c2edb29bdfe27f0a7f107083804c
3
+ metadata.gz: efad11cd31d73aa3039a04ab64284a855615bb8d407691072cb846e56dfcacdc
4
+ data.tar.gz: f3fb62707f1b43cc4b3cd24dddad6729e3eb3843e268f8414f063f3da4c452a5
5
5
  SHA512:
6
- metadata.gz: 70a6c4abc45ea146e15727fd1fc3cd5842b83a779112530cb333f401e4de5b39f63e6fda9cf15d785476b5c6a0d122660bfb7a28cf6aa28c18d7a498ae0f5833
7
- data.tar.gz: 59709a1f78ccdf10579cdb5849d03fb18c5cd898238286af6762352187493c01fce9c6d8b4c0f4409dbb5e7b18bba81e77509496eca0e5ceb1ee684d78478d48
6
+ metadata.gz: 260d5aac97e2ff84c940bc085599fae770a4f545d94127b2bfe133fe1257e3fcef379851a8028d14b8ff2fd025eaff4ecb933ca766345d724b92aeb9fef40a10
7
+ data.tar.gz: '088f1d7a2ceafe1c04270bce0b5b28172a659a51acb5b7f068aaedb0902b887088e67cecc28902fc79d32500e9b3a33a9b5a6c9a413731e33924fe4bf92d2e80'
data/lib/lazy_rsa.rb CHANGED
@@ -9,7 +9,8 @@ module LazyRsa
9
9
 
10
10
  def decrypt(key, ciphertext)
11
11
  key = read_key(key)
12
- OpenSSL::BN.new(ciphertext).mod_exp(key.d, key.n).to_i
12
+ integer = OpenSSL::BN.new(ciphertext).mod_exp(key.d, key.n)
13
+ integer_to_text(integer)
13
14
  end
14
15
 
15
16
  def generate_key
@@ -26,7 +27,7 @@ module LazyRsa
26
27
  build_key(e:, d:, n:)
27
28
  end
28
29
 
29
- def build_key(e:, d: nil, n:)
30
+ def build_key(e: nil, d: nil, n:)
30
31
  data_sequence = OpenSSL::ASN1::Sequence([
31
32
  OpenSSL::ASN1::Integer(n),
32
33
  OpenSSL::ASN1::Integer(e),
@@ -45,5 +46,9 @@ module LazyRsa
45
46
  def text_to_integer(text)
46
47
  OpenSSL::BN.new(text.unpack("H*").first.to_i(16))
47
48
  end
49
+
50
+ def integer_to_text(integer)
51
+ [integer.to_s(16)].pack("H*")
52
+ end
48
53
  end
49
54
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lazy_rsa
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
  - Nick Quaranto
@@ -37,7 +37,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
37
37
  - !ruby/object:Gem::Version
38
38
  version: '0'
39
39
  requirements: []
40
- rubygems_version: 3.4.19
40
+ rubygems_version: 3.1.2
41
41
  signing_key:
42
42
  specification_version: 4
43
43
  summary: Easy RSA