It would not make sense. When the same (stream) cipher is initialized with the same key
and iv
, the state of the cipher should be exactly the same, regardless of Operating System, programming language, or any other external influences. This is the case by definition of these kind of cipher algorithms. It is also the reason why a random iv
+key
combination is necessary for each new piece of information you want to encrypt (re-using them will make the cipher predictable).
I just copied over the iv
and key
binaries that your IEx gave back, and on Linux Mint I got the following result:
iex(45)> iv = <<142, 93, 70, 234, 188, 142, 90, 77, 140, 93, 219, 36, 69, 159, 95, 171>>
<<142, 93, 70, 234, 188, 142, 90, 77, 140, 93, 219, 36, 69, 159, 95, 171>>
iex(46)> key = <<160, 142, 195, 53, 122, 138, 78, 212, 131, 136, 1, 56, 195, 181, 236, 144,
...(46)> 161, 220, 39, 183, 165, 176, 216, 247, 100, 229, 246, 145, 250, 153, 119, 80>>
<<160, 142, 195, 53, 122, 138, 78, 212, 131, 136, 1, 56, 195, 181, 236, 144,
161, 220, 39, 183, 165, 176, 216, 247, 100, 229, 246, 145, 250, 153, 119, 80>>
iex(47)> init = :crypto.stream_init(:aes_ctr, key, iv)
{:aes_ctr,
{<<160, 142, 195, 53, 122, 138, 78, 212, 131, 136, 1, 56, 195, 181, 236, 144,
161, 220, 39, 183, 165, 176, 216, 247, 100, 229, 246, 145, 250, 153, 119,
80>>,
<<142, 93, 70, 234, 188, 142, 90, 77, 140, 93, 219, 36, 69, 159, 95, 171>>,
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0>>, 0}}
iex(48)> :crypto.stream_encrypt(init, "the quick brown fox jumps over the lazy dog")
{{:aes_ctr,
{<<160, 142, 195, 53, 122, 138, 78, 212, 131, 136, 1, 56, 195, 181, 236, 144,
161, 220, 39, 183, 165, 176, 216, 247, 100, 229, 246, 145, 250, 153, 119,
80>>,
<<142, 93, 70, 234, 188, 142, 90, 77, 140, 93, 219, 36, 69, 159, 95, 174>>,
<<145, 85, 24, 187, 212, 168, 150, 78, 166, 93, 3, 88, 175, 160, 207, 116>>,
11}},
<<59, 68, 179, 50, 61, 72, 75, 248, 36, 120, 9, 239, 37, 9, 135, 230, 25, 86,
118, 143, 40, 228, 116, 148, 142, 198, 201, 222, 2, 173, 44, 205, 249, 48,
56, 215, 181, 210, 239, 110, 194, 50, 100>>}
I would expect this result to be 1:1 the same on different computer systems. I am very confused about the empty binary you got as a result the first time.