swak 0.1.2 → 0.1.3
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/lib/swak.rb +1 -0
- data/lib/swak/crypt.rb +25 -0
- metadata +3 -2
data/lib/swak.rb
CHANGED
data/lib/swak/crypt.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'digest/sha2'
|
2
|
+
require 'openssl'
|
3
|
+
|
4
|
+
module Swak
|
5
|
+
# Uses AES-256-ECB encryption, outputs a string
|
6
|
+
# - encrypted_data: an encrypted data string output by encrypt
|
7
|
+
# - key: plain text key (uses SHA2 to digest it into a form openssh can use)
|
8
|
+
def Swak.decrypt(encrypted_data, key)
|
9
|
+
aes = OpenSSL::Cipher::Cipher.new("AES-256-ECB")
|
10
|
+
aes.decrypt
|
11
|
+
aes.key = Digest::SHA1.hexdigest(key)
|
12
|
+
aes.update(encrypted_data) + aes.final
|
13
|
+
end
|
14
|
+
|
15
|
+
# Uses AES-256-ECB encryption, outputs a string
|
16
|
+
# - data: A string of data
|
17
|
+
# - key: plain text key (uses SHA2 to digest it into a form openssh can use)
|
18
|
+
def Swak.encrypt(data, key)
|
19
|
+
aes = OpenSSL::Cipher::Cipher.new("AES-256-ECB")
|
20
|
+
aes.encrypt
|
21
|
+
aes.key = Digest::SHA1.hexdigest(key)
|
22
|
+
aes.update(data) + aes.final
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: swak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.1.
|
5
|
+
version: 0.1.3
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Jesse Rodriguez
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-07-10 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: Random tools and mixins
|
@@ -23,6 +23,7 @@ extra_rdoc_files: []
|
|
23
23
|
|
24
24
|
files:
|
25
25
|
- lib/swak.rb
|
26
|
+
- lib/swak/crypt.rb
|
26
27
|
- lib/swak/interval.rb
|
27
28
|
- lib/swak/logger.rb
|
28
29
|
homepage: http://rubygems.org/gems/swak
|