Sha256: c8500e74d711528d12d69e2cc2877e39190609f776d6d409af8075fe7b7351de
Contents?: true
Size: 639 Bytes
Versions: 1
Compression:
Stored size: 639 Bytes
Contents
require "openssl" require "base64" module Parsel autoload :Version, "parsel/version" def self.encrypt(key, data) encode cipher(:encrypt, key, data) end def self.decrypt(key, data) cipher(:decrypt, key, decode(data)) rescue Exception false end private def self.cipher(mode, key, data) cipher = OpenSSL::Cipher.new("AES-256-CBC").public_send(mode) cipher.key = Digest::SHA256.digest(key) cipher.iv = "f89209ffcdd1a225" cipher.update(data) + cipher.final end def self.encode(data) Base64.encode64(data).gsub(/\n/, "") end def self.decode(data) Base64.decode64(data) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
parsel-0.1.1 | lib/parsel.rb |