class Match::Encryption::MatchFileEncryption
The methods of this class will encrypt or decrypt files in place, by default.
Public Instance Methods
decrypt(file_path:, password:, output_path: nil)
click to toggle source
# File match/lib/match/encryption/encryption.rb, line 145 def decrypt(file_path:, password:, output_path: nil) output_path = file_path unless output_path content = File.read(file_path) e = MatchDataEncryption.new decrypted_data = e.decrypt(base64encoded_encrypted: content, password: password) File.binwrite(output_path, decrypted_data) end
encrypt(file_path:, password:, output_path: nil, version: 2)
click to toggle source
# File match/lib/match/encryption/encryption.rb, line 137 def encrypt(file_path:, password:, output_path: nil, version: 2) output_path = file_path unless output_path data_to_encrypt = File.binread(file_path) e = MatchDataEncryption.new data = e.encrypt(data: data_to_encrypt, password: password, version: version) File.write(output_path, data) end