sodium.cr/spec/cox/secret_box_spec.cr
Didactic Drunk 848cf3e3e2 Breaking API changes:
SecretKey renamed to SecretBox.

Start of automatic wiping.
Documentation additions and corrections.
2019-06-28 05:20:56 -07:00

16 lines
418 B
Crystal

require "../spec_helper"
describe Cox::SecretBox do
it "encrypts/decrypts" do
key = Cox::SecretBox.new
message = "foobar"
encrypted, nonce = key.encrypt_easy message
decrypted = key.decrypt_easy encrypted, nonce
message.should eq String.new(decrypted)
expect_raises(Cox::Error::DecryptionFailed) do
key.decrypt_easy "badmsgbadmsgbadmsgbadmsgbadmsg".to_slice, nonce
end
end
end