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.
- checksums.yaml +4 -4
- data/lib/lazy_rsa.rb +7 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efad11cd31d73aa3039a04ab64284a855615bb8d407691072cb846e56dfcacdc
|
4
|
+
data.tar.gz: f3fb62707f1b43cc4b3cd24dddad6729e3eb3843e268f8414f063f3da4c452a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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
|
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.
|
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.
|
40
|
+
rubygems_version: 3.1.2
|
41
41
|
signing_key:
|
42
42
|
specification_version: 4
|
43
43
|
summary: Easy RSA
|