This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
HPWebcamAble's profile picture

Encryption changes every time

Started by HPWebcamAble, 28 June 2015 - 06:15 PM
HPWebcamAble #1
Posted 28 June 2015 - 08:15 PM
I've written a quick proof-of-concept encryption program.
It isn't anything special yet, it uses SquidDev's AES API for encryption and decryption, though I have big plans ;)/>

Main program: http://pastebin.com/mX58vjWD
AES API: http://pastebin.com/r3CkkGsw
(You must name the api 'aes')

You enter a key and a secret, the program encrypts them, saves the result to a file (save.pass), then reads the file and decrypts it using the original key.

It spits out the correct result, but if you continuously enter the same password and the same key, the encryption always different…
And it correctly decrypts…

WHY?



Note that if you get the error 'newline Detected', it is to show when a newline (\n) was generated in the encryption
That is a story for another day…
Anavrins #2
Posted 28 June 2015 - 10:56 PM
That's because Squid's AES uses the the CBC mode of encryption, which requires a random IV for each encryption, see https://en.m.wikipedia.org/wiki/Block_cipher_mode_of_operation

I'm not sure how SquidDev's api works, but you should be able to retrive the IV somehow.
HPWebcamAble #3
Posted 29 June 2015 - 12:56 AM
That's because Squid's AES uses the the CBC mode of encryption, which requires a random IV for each encryption, see https://en.m.wikiped...de_of_operation

I'm not sure how SquidDev's api works, but you should be able to retrive the IV somehow.

Oh ok that makes more sense, it creates some random characters to make it appear different each time.

Thanks :)/>