test/cipher_test.rb in symmetric-encryption-3.4.0 vs test/cipher_test.rb in symmetric-encryption-3.6.0
- old
+ new
@@ -5,22 +5,22 @@
class CipherTest < Test::Unit::TestCase
context 'standalone' do
should "allow setting the cipher_name" do
cipher = SymmetricEncryption::Cipher.new(
- :cipher_name => 'aes-128-cbc',
- :key => '1234567890ABCDEF1234567890ABCDEF',
- :iv => '1234567890ABCDEF',
- :encoding => :none
+ cipher_name: 'aes-128-cbc',
+ key: '1234567890ABCDEF1234567890ABCDEF',
+ iv: '1234567890ABCDEF',
+ encoding: :none
)
assert_equal 'aes-128-cbc', cipher.cipher_name
end
should "not require an iv" do
cipher = SymmetricEncryption::Cipher.new(
- :key => '1234567890ABCDEF1234567890ABCDEF',
- :encoding => :none
+ key: '1234567890ABCDEF1234567890ABCDEF',
+ encoding: :none
)
result = "\302<\351\227oj\372\3331\310\260V\001\v'\346"
# Note: This test fails on JRuby 1.7 RC1 since it's OpenSSL
# behaves differently when no IV is supplied.
# It instead encrypts to the following value:
@@ -29,14 +29,14 @@
assert_equal result, cipher.encrypt('Hello World')
end
should "throw an exception on bad data" do
cipher = SymmetricEncryption::Cipher.new(
- :cipher_name => 'aes-128-cbc',
- :key => '1234567890ABCDEF1234567890ABCDEF',
- :iv => '1234567890ABCDEF',
- :encoding => :none
+ cipher_name: 'aes-128-cbc',
+ key: '1234567890ABCDEF1234567890ABCDEF',
+ iv: '1234567890ABCDEF',
+ encoding: :none
)
assert_raise OpenSSL::Cipher::CipherError do
cipher.decrypt('bad data')
end
end
@@ -113,21 +113,21 @@
end
context 'with configuration' do
setup do
@cipher = SymmetricEncryption::Cipher.new(
- :key => '1234567890ABCDEF1234567890ABCDEF',
- :iv => '1234567890ABCDEF',
- :encoding => :none
+ key: '1234567890ABCDEF1234567890ABCDEF',
+ iv: '1234567890ABCDEF',
+ encoding: :none
)
@social_security_number = "987654321"
@social_security_number_encrypted = "A\335*\314\336\250V\340\023%\000S\177\305\372\266"
@social_security_number_encrypted.force_encoding('binary') if defined?(Encoding)
@sample_data = [
- { :text => '555052345', :encrypted => ''}
+ { text: '555052345', encrypted: ''}
]
end
should "default to 'aes-256-cbc'" do
assert_equal 'aes-256-cbc', @cipher.cipher_name
@@ -147,10 +147,10 @@
assert_equal random_cipher.cipher_name, header.cipher_name, "Ciphers differ"
assert_equal random_cipher.send(:key), header.key, "Keys differ"
assert_equal random_cipher.send(:iv), header.iv, "IVs differ"
string = "Hello World"
- cipher = SymmetricEncryption::Cipher.new(:key => header.key, :iv => header.iv, :cipher_name => header.cipher_name)
+ cipher = SymmetricEncryption::Cipher.new(key: header.key, iv: header.iv, cipher_name: header.cipher_name)
# Test Encryption
assert_equal random_cipher.encrypt(string, false, false), cipher.encrypt(string, false, false), "Encrypted values differ"
end
should "encrypt and then decrypt without a header" do
\ No newline at end of file