event-shipper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/producer +1 -1
- data/lib/event_shipper/transport/encrypt.rb +8 -6
- metadata +1 -1
data/bin/producer
CHANGED
@@ -31,20 +31,21 @@ module EventShipper::Transport
|
|
31
31
|
def enc str
|
32
32
|
cipher = OpenSSL::Cipher::AES256.new(:CBC)
|
33
33
|
cipher.encrypt
|
34
|
-
|
34
|
+
iv = cipher.random_iv
|
35
35
|
cipher.key = @key
|
36
36
|
|
37
37
|
ciphertext = cipher.update(str) + cipher.final
|
38
38
|
|
39
|
-
"
|
39
|
+
"#@salt#{iv}#{ciphertext}"
|
40
40
|
end
|
41
41
|
def dec str
|
42
|
-
salt = str[8
|
43
|
-
|
44
|
-
|
42
|
+
salt = str[0,8]
|
43
|
+
iv = str[8,16]
|
44
|
+
str = str[24..-1]
|
45
|
+
|
45
46
|
cipher = OpenSSL::Cipher::AES256.new(:CBC)
|
46
47
|
cipher.decrypt
|
47
|
-
|
48
|
+
cipher.iv = iv
|
48
49
|
cipher.key = generate_key(@password, salt)
|
49
50
|
|
50
51
|
cipher.update(str) + cipher.final
|
@@ -88,6 +89,7 @@ if $0 == __FILE__
|
|
88
89
|
|
89
90
|
dec = EventShipper::Transport::Encryption.new 'password'
|
90
91
|
puts dec.dec(str)
|
92
|
+
exit
|
91
93
|
|
92
94
|
require 'benchmark'
|
93
95
|
puts "Doing it a 1000 times"
|