cryptatron 0.0.4 → 0.0.8

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/cryptatron.rb CHANGED
@@ -3,21 +3,24 @@ require 'yaml'
3
3
  require 'gibberish'
4
4
 
5
5
  module Cryptatron
6
- def self.encrypt(body)
6
+ def self.encrypt(body, magic)
7
7
  setup
8
8
 
9
9
  begin
10
- Base64.strict_encode64 @cipher.encrypt(body, binary: true)
10
+ Base64.strict_encode64 @cipher.encrypt(magic + body, binary: true)
11
11
  rescue
12
12
  nil
13
13
  end
14
14
  end
15
15
 
16
- def self.decrypt(body)
16
+ def self.decrypt(body, magic)
17
17
  setup
18
18
 
19
19
  begin
20
- @cipher.decrypt(body)
20
+ body = @cipher.decrypt(body)
21
+ raise unless body.starts_with?(magic)
22
+
23
+ return body[magic.length..-1]
21
24
  rescue
22
25
  nil
23
26
  end
@@ -1,3 +1,3 @@
1
1
  module Cryptatron
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.8'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptatron
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-05-14 00:00:00.000000000 Z
13
+ date: 2013-05-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: gibberish