Fix decryption IV

This commit is contained in:
Justin Collins
2020-03-18 09:07:28 -07:00
parent 70d41440c4
commit 7e25fd0f6c
2 changed files with 25 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
# frozen_string_literal: true
require "spec_helper"
require_relative "../../lib/encryption"
describe Encryption do
let(:value) {
allow(Encryption).to receive(:key).and_return(SecureRandom.bytes(32))
allow(Encryption).to receive(:iv).and_return(SecureRandom.bytes(16))
"OMG PII"
}
it "encrypts values" do
encrypted = Encryption.encrypt_sensitive_value(value)
expect(Base64.decode64(encrypted)).not_to eq(value)
end
it "decrypts values" do
encrypted = Encryption.encrypt_sensitive_value(value)
decrypted = Encryption.decrypt_sensitive_value(encrypted)
expect(decrypted).to eq(value)
end
end