Sha256: e33c34a6a63f2c90fcd1b4cd29d65888efbc54b6bd516ab138acb986bc5a1d9b
Contents?: true
Size: 879 Bytes
Versions: 5
Compression:
Stored size: 879 Bytes
Contents
require 'base64' module Encryption module String def encrypt(options = {}) string = encryptor(options).encrypt self string = Base64.encode64(string) if options[:encode] string end def decrypt(options = {}) string = self string = Base64.decode64(self) if options[:encode] or options[:encoded] encryptor(options).decrypt string end def encrypt!(options = {}) replace encrypt(options) end def decrypt!(options = {}) replace decrypt(options) end private def encryptor(options) return Encryption if options.empty? return options[:encryptor] if ! options[:encryptor].nil? encrypt = Encryption::Symmetric.new options.each do |key, value| encrypt.send(key.to_s + '=', value) if encrypt.respond_to? key.to_s + '=' end encrypt end end end
Version data entries
5 entries across 5 versions & 1 rubygems