irb(main):001:0> require 'openssl'
=> true
irb(main):002:0> message = "whatever"
=> "whatever"
irb(main):003:0> @sha256 = OpenSSL::Digest::SHA256.new
=> #<OpenSSL::Digest::SHA256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855>
irb(main):004:0> @cipher = OpenSSL::Cipher::Cipher.new("AES-256-CTR")
=> #<OpenSSL::Cipher::Cipher:0x00000002467830>
irb(main):005:0> 2.times do
irb(main):006:1* key = @sha256.digest("whatever")
irb(main):007:1> @sha256.reset
irb(main):008:1> @cipher.encrypt
irb(main):009:1> @cipher.key = key
irb(main):010:1> ciphertext = @cipher.update(message)
irb(main):011:1> ciphertext << @cipher.final
irb(main):012:1> @cipher.reset
irb(main):013:1> puts ciphertext
irb(main):014:1> end
axtT
9]K/
=> 2