rsa-encrypter 0.0.3 → 0.1.0
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 +44 -5
- data/lib/rsa-encrypter/version.rb +1 -1
- data/lib/rsa-encrypter.rb +4 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
|
3
3
|
Gem is in development-mode
|
4
4
|
|
5
|
+
## Developer
|
6
|
+
|
7
|
+
Cevin Eichnau
|
8
|
+
|
9
|
+
www.eichnau.com
|
10
|
+
|
5
11
|
## Installation
|
6
12
|
|
7
13
|
Add this line to your application's Gemfile:
|
@@ -20,16 +26,49 @@ Or install it yourself as:
|
|
20
26
|
|
21
27
|
example to use :
|
22
28
|
|
29
|
+
generate public and private key
|
30
|
+
|
31
|
+
key = Rsa::Encrypter.generate_rsa
|
32
|
+
|
33
|
+
a sample message to encrypting (m)
|
34
|
+
|
35
|
+
puts "your message ?"
|
36
|
+
|
37
|
+
print "=> "; m = gets.chomp
|
38
|
+
|
39
|
+
e is the encrypted message encrypt needs 3 args 1 = message, 2 = public key (key[1]) and 3 =(key[0]) for calculate with public key
|
40
|
+
|
41
|
+
e = Rsa::Encrypter.encrypt(m, key[1], key[0])
|
42
|
+
|
43
|
+
decrypt needs to 3 args 1:mesage, 2:private key (key[2]) and 3: (key[0]) dor calculate with private key
|
44
|
+
|
45
|
+
puts Rsa::Encrypter.decrypt(e, key[2], key[0])
|
46
|
+
|
47
|
+
## Time
|
48
|
+
|
49
|
+
enter your message
|
50
|
+
|
51
|
+
=> ruby
|
52
|
+
|
53
|
+
decrypted message :
|
54
|
+
|
55
|
+
=> ruby
|
56
|
+
|
57
|
+
time to need for en/decrypting the message
|
58
|
+
|
59
|
+
|------------------------------------------------------------|
|
60
|
+
|
61
|
+
Time elapsed encrypt 0.8540000000000001 milliseconds
|
23
62
|
|
24
|
-
|
63
|
+
|------------------------------------------------------------|
|
25
64
|
|
26
|
-
|
65
|
+
Time elapsed decrypt 2130.5420000000004 milliseconds
|
27
66
|
|
28
|
-
|
67
|
+
|------------------------------------------------------------|
|
29
68
|
|
30
|
-
|
69
|
+
Time elapsed all 2131.4030000000002 milliseconds
|
31
70
|
|
32
|
-
|
71
|
+
|------------------------------------------------------------|
|
33
72
|
|
34
73
|
## Todo
|
35
74
|
|
data/lib/rsa-encrypter.rb
CHANGED
@@ -23,7 +23,7 @@ module Rsa
|
|
23
23
|
limit = x / i
|
24
24
|
while i < limit
|
25
25
|
if x % i == 0
|
26
|
-
raise "
|
26
|
+
raise "#{x} not prime"
|
27
27
|
end
|
28
28
|
i += 1
|
29
29
|
limit = x / i
|
@@ -31,10 +31,10 @@ module Rsa
|
|
31
31
|
return x
|
32
32
|
end
|
33
33
|
|
34
|
-
def self.generate_rsa
|
34
|
+
def self.generate_rsa(a=1033, b=977)
|
35
35
|
|
36
|
-
p = prime?(
|
37
|
-
q = prime?(
|
36
|
+
p = prime?(a)
|
37
|
+
q = prime?(b)
|
38
38
|
n = p * q
|
39
39
|
n2 = (p-1)*(q-1)
|
40
40
|
e = (p+q) -1
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsa-encrypter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-14 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: rsa-encrypter to encrypt messages like password usw
|
15
15
|
email:
|