Sha256: 0605b7c09544c9626d1558133f7a0f67ebc50981075cb3bb3cd414ff08a06396

Contents?: true

Size: 692 Bytes

Versions: 19

Compression:

Stored size: 692 Bytes

Contents

require 'helper'

module Bixby
module Test

class TestCryptoUtil < TestCase

  def test_crypto_cycle

    key1 = CryptoUtil.generate_keypair
    key2 = CryptoUtil.generate_keypair

    data = {"foo" => "bar"}
    uuid = "123456"

    encrypted = CryptoUtil.encrypt(MultiJson.dump(data), uuid, key1, key2)
    assert encrypted
    encrypted_io = StringIO.new(encrypted)
    assert_equal uuid, encrypted_io.readline.strip

    decrypted = CryptoUtil.decrypt(encrypted_io, key1, key2)
    assert decrypted
    data_out = MultiJson.load(decrypted)
    assert data_out
    assert_kind_of Hash, data_out
    assert_equal "bar", data_out["foo"]
  end


end # TestCryptoUtil

end # Test
end # Bixby

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bixby-common-0.7.1 test/util/crypto_util_test.rb
bixby-common-0.7.0 test/util/crypto_util_test.rb
bixby-common-0.6.6 test/util/crypto_util_test.rb
bixby-common-0.6.5 test/util/crypto_util_test.rb
bixby-common-0.6.4 test/util/crypto_util_test.rb
bixby-common-0.6.3 test/util/crypto_util_test.rb
bixby-common-0.6.2 test/util/crypto_util_test.rb
bixby-common-0.6.1 test/util/crypto_util_test.rb
bixby-common-0.6.0 test/util/crypto_util_test.rb
bixby-common-0.5.0 test/util/crypto_util_test.rb
bixby-common-0.4.13 test/util/crypto_util_test.rb
bixby-common-0.4.12 test/util/crypto_util_test.rb
bixby-common-0.4.11 test/util/crypto_util_test.rb
bixby-common-0.4.10 test/util/crypto_util_test.rb
bixby-common-0.4.9 test/util/crypto_util_test.rb
bixby-common-0.4.8 test/util/crypto_util_test.rb
bixby-common-0.4.7 test/util/crypto_util_test.rb
bixby-common-0.4.6 test/util/crypto_util_test.rb
bixby-common-0.4.5 test/util/crypto_util_test.rb