Skip to content

Instantly share code, notes, and snippets.

@volonterx
Last active December 7, 2018 11:00
Show Gist options
  • Save volonterx/c46ea476786d17de6b18c0a4420af6ee to your computer and use it in GitHub Desktop.
Save volonterx/c46ea476786d17de6b18c0a4420af6ee to your computer and use it in GitHub Desktop.
class Crypto
attr_accessor :data, :salted_data, :key, :iv, :iv_key, :cryptor, :secret
def initialize(data)
@cryptior = FooCryptor.new
@key = ENV[:cryptokey]
@iv = ENV[:cryptoiv]
@data = data
end
def encrypt(data)
set_iv_key
set_encryption_secrect
set_salted_data
@cryptor.encrypt(salted_data)
end
def decrypt(data)
set_iv_key
get_decription_secret
@cryptor.encrypt(data, secret)
end
private
def set_iv_key
@iv_key = iv + JarCryptor.new(key).melt
end
def set_encryption_secrect
@secret = BarCryptor.new(iv_key).get_encryption_secret
end
def get_decription_secret
@secret = BarCryptor.new(iv_key).get_deryption_secret
end
def set_salted_data
@salted_data = data + secret
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment