I have 2 methods to generate 2 different data and need to save them in one encrypted file.
Can I achieve this by adding encrypted stringA + encrypted stringB, then decrypt them later?
Or
I have to encrpt stringA -> save as file -> read the file & decrypt to stringA -> stringA + stringB -> encrypt ?
NB, I am using Rijndael(AES) and someone suggested using customerized stream, will it work?
Any thoughts? Many thanks~
If you're using ECB (electronic code book), then it should be possible (assuming they use the same encryption key), because each block is decrypted independent of other blocks. If you're using CBC (cipher block chaining) this will not work because each block is encrypted using data from the previous block. However, using ECB is way less secure than CBC.
If you encrypt each separately, and know the length of each block of encrypted text, you can decrypt them later individually.
Something like this format would probably work:
Message1Length
Message1Content
Message2Content
Read the Message1Length number of bytes into the message and store it as encryptedMessage1 or something. Then read from that point to the End of File and store it as encryptedMessage2. Then decrypt them both individually.
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