aes
aes copied to clipboard
Test cases should be more comprehensive
Right now there's only a few test cases in here, and for the most part they just ensure that the encrypt
and decrypt
methods roundtrip. There should be quite a few more, including some that test that the data does indeed get encrypted, and that different keys don't work. For e.g.
should "encrypt should encrypt" do
key = "01234567890123456789012345678901"
msg = "This is a message that nobody should ever see"
enc = AES.encrypt(msg, key)
assert_not_equal msg, enc
enc = AES.encrypt(msg, key, {:format => :plain})
assert_not_equal msg, enc
end
should "key changes shouldn't decrypt correctly" do
key1 = "01234567890123456789012345678901"
key2 = "01234567890123456789012345678902"
msg = "This is a message that nobody should ever see"
enc = AES.encrypt(msg, key1)
assert_not_equal msg, AES.decrypt(enc, key2)
enc = AES.encrypt(msg, key1, {:format => :plain})
assert_not_equal msg, AES.decrypt(enc, key2, {:format => :plain})
end
(not sure if these run, don't have a ruby env at the moment and I'm not that great with ruby)
A bunch more should be added, including standard ones like this but these might at least get that started