When using blowfish algorithm from openssl library, one can encrypt and decrypt any data.
Furthermore any data can be encrypted (decrypted) with any key\iv. There is no way in openssl to tell whether decryption was successful or not. It's just some mathematical transformation.
So, what should I do to be sure that encryption was successful: that some data was decrypted with same key/iv which it was encrypted?
Should I add some MAGIC bytes in front of data that should be checked after decryption?
The average time for encrypting/decrypting 3mb file is about 1.5 sec. It can be different when you work with streams and takes like 1 sec or even less.
256-bit encryption is refers to the length of the encryption key used to encrypt a data stream or file. A hacker or cracker will require 2256 different combinations to break a 256-bit encrypted message, which is virtually impossible to be broken by even the fastest computers.
As shown above, even with a supercomputer, it would take 1 billion billion years to crack the 128-bit AES key using brute force attack. This is more than the age of the universe (13.75 billion years).
Messages and files are encrypted before they leave the phone or computer and aren't decrypted until they reach their destination. Hackers can't access data on the server because they don't have the private keys required to decrypt the data. Instead, secret keys are stored on the individual user's device.
You can add a checksum (for instance, MD5 of the original content) at the end of the file. After you decrypt it, the last 16 bytes must again be equal to md5(content-16 bytes)
Of the many possible solutions, maybe consider using a CRC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With