92ac0ef6d4
Rearrange CryptoBox. Move Sodium::Error to it's own file. Requiring individual files is now possible. Individual require now possible.
18 lines
465 B
Crystal
18 lines
465 B
Crystal
require "../spec_helper"
|
|
require "../../src/sodium/secret_box"
|
|
|
|
describe Sodium::SecretBox do
|
|
it "encrypts/decrypts" do
|
|
key = Sodium::SecretBox.new
|
|
|
|
message = "foobar"
|
|
encrypted, nonce = key.encrypt_easy message
|
|
decrypted = key.decrypt_easy encrypted, nonce
|
|
message.should eq String.new(decrypted)
|
|
|
|
expect_raises(Sodium::Error::DecryptionFailed) do
|
|
key.decrypt_easy "badmsgbadmsgbadmsgbadmsgbadmsg".to_slice, nonce
|
|
end
|
|
end
|
|
end
|