lib/parsel.rb in parsel-0.1.1 vs lib/parsel.rb in parsel-0.2.0
- old
+ new
@@ -1,11 +1,13 @@
-require "openssl"
-require "base64"
+require 'openssl'
+require 'base64'
+require 'json'
+require 'parsel/marshal'
+require 'parsel/json'
+require 'parsel/version'
module Parsel
- autoload :Version, "parsel/version"
-
def self.encrypt(key, data)
encode cipher(:encrypt, key, data)
end
def self.decrypt(key, data)
@@ -14,17 +16,17 @@
false
end
private
def self.cipher(mode, key, data)
- cipher = OpenSSL::Cipher.new("AES-256-CBC").public_send(mode)
+ cipher = OpenSSL::Cipher.new('AES-256-CBC').public_send(mode)
cipher.key = Digest::SHA256.digest(key)
- cipher.iv = "f89209ffcdd1a225"
+ cipher.iv = 'f89209ffcdd1a225'
cipher.update(data) + cipher.final
end
def self.encode(data)
- Base64.encode64(data).gsub(/\n/, "")
+ Base64.encode64(data).gsub(/\n/, '')
end
def self.decode(data)
Base64.decode64(data)
end