Sha256: 4a6e974689c3adc6f41ffb00a5a4831b8e2dc368f83faeaa2a0f3944ffd7b216
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'base64' require 'yaml' # Lightweight obfuscation wrapper used to obfuscate account.yml file. # # CAUTION; this is not intended to be a robust security mechanism. It is simple # obfuscation (security through obscurity). There's no strong reason why we couldn't # store the credentials in clear text, but just taking an extra step to prevent trouble. module Spec module Obfuscation def encrypt(data) rot13(Base64.encode64(data)) end def decrypt(data) Base64.decode64(rot13(data)) end def rot13(data) data.tr!("A-Za-z", "N-ZA-Mn-za-m") end def encrypt_file(file) data = read_if_exist!(file) begin File.open("#{file}.obfus", 'w') { |file| file.write(encrypt(data)) } rescue Exception => e raise "Unable to encrypt #{file}" end end def decrypt_file(file) data = read_if_exist!(file) begin return ::YAML::load(decrypt(data)) rescue Exception => e raise "Unable to decrypt #{file}" end end def read_if_exist!(file) return IO.read(file) if File.exist?(file) raise "File not found #{file}" end extend self end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gmail-0.7.1 | spec/support/obfuscation.rb |
gmail-0.7.0 | spec/support/obfuscation.rb |