rsa-encrypter 0.2.1 → 0.2.2
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 +8 -4
- data/lib/rsa-encrypter.rb +2 -2
- data/lib/rsa-encrypter/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -18,9 +18,11 @@ And then execute:
|
|
18
18
|
|
19
19
|
$ bundle
|
20
20
|
|
21
|
-
Or install it yourself
|
21
|
+
Or install it yourself and require in your ruby file:
|
22
22
|
|
23
23
|
$ gem install rsa-encrypter
|
24
|
+
require "rsa-encrypter"
|
25
|
+
|
24
26
|
|
25
27
|
## Usage
|
26
28
|
|
@@ -30,9 +32,10 @@ generate public and private key
|
|
30
32
|
|
31
33
|
key = Rsa::Encrypter.generate_rsa
|
32
34
|
|
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
35
|
|
35
|
-
|
36
|
+
or you can set the both prime numbers manualy (1-6), default is 5 (secure but slow) when the secure level smaller than is the encrypter faster but less secure
|
37
|
+
|
38
|
+
key = Rsa::Encrypter.generate_rsa(3)
|
36
39
|
|
37
40
|
a sample message to encrypting (m)
|
38
41
|
|
@@ -58,7 +61,8 @@ decrypted message :
|
|
58
61
|
|
59
62
|
=> ruby
|
60
63
|
|
61
|
-
time to need for en/decrypting the message
|
64
|
+
time to need for en/decrypting the message by secure level 6
|
65
|
+
|
62
66
|
|
63
67
|
|------------------------------------------------------------|
|
64
68
|
|
data/lib/rsa-encrypter.rb
CHANGED
@@ -32,9 +32,9 @@ module Rsa
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.generate_rsa(a=5)
|
35
|
-
secure = [ [11,13], [61,53], [
|
35
|
+
secure = [ [11,13], [61,53], [163,181], [443,463], [859,769], [1033,977] ]
|
36
36
|
a-=1
|
37
|
-
raise "wrong secure level: #{a+1} please use level 1-
|
37
|
+
raise "wrong secure level: #{a+1} please use level 1-6" if a > 5 or a < 0
|
38
38
|
p = prime?(secure[a][0])
|
39
39
|
q = prime?(secure[a][1])
|
40
40
|
n = p * q
|