rsa-encrypter 0.1.1 → 0.2.1
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.
- data/README.md +2 -2
- data/lib/rsa-encrypter/version.rb +1 -1
- data/lib/rsa-encrypter.rb +6 -4
- metadata +1 -1
data/README.md
CHANGED
@@ -30,9 +30,9 @@ generate public and private key
|
|
30
30
|
|
31
31
|
key = Rsa::Encrypter.generate_rsa
|
32
32
|
|
33
|
-
or you can set the both prime numbers manualy, default is
|
33
|
+
or you can set the both prime numbers manualy (1-7), default is 7 (secure but slow) when the secure level smaller than is the encrypter faster but less secure
|
34
34
|
|
35
|
-
key = Rsa::Encrypter.generate_rsa(
|
35
|
+
key = Rsa::Encrypter.generate_rsa(2)
|
36
36
|
|
37
37
|
a sample message to encrypting (m)
|
38
38
|
|
data/lib/rsa-encrypter.rb
CHANGED
@@ -31,10 +31,12 @@ module Rsa
|
|
31
31
|
return x
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.generate_rsa(a=
|
35
|
-
|
36
|
-
|
37
|
-
|
34
|
+
def self.generate_rsa(a=5)
|
35
|
+
secure = [ [11,13], [61,53], [71,76], [163,181], [443,463], [859,769], [1033,977] ]
|
36
|
+
a-=1
|
37
|
+
raise "wrong secure level: #{a+1} please use level 1-7" if a > 6 or a < 0
|
38
|
+
p = prime?(secure[a][0])
|
39
|
+
q = prime?(secure[a][1])
|
38
40
|
n = p * q
|
39
41
|
n2 = (p-1)*(q-1)
|
40
42
|
e = (p+q) -1
|