EldoS | Feel safer!

Software components for data protection, secure storage and transfer

PGP Encrypt a file & always have the same output, possible?

Posted: 08/08/2012 17:08:54
by K Gdhami (Standard support level)
Joined: 06/29/2012
Posts: 4


OK, it took me a while to figure things out but now I have the encryption (using Delphi 2010) and decryption (via PHP) working just fine.

My question is: can I configure SecureBlackbox (VCL / Delphi 2010) so that encrypted output/file is always the same?

In other words, let's say I have a file called test-file.bin, I encrypt it twice (using the same PGP parameters, keys, etc...):

test-file.bin --> test-file_1.encr
test-file.bin --> test-file_2.encr

and have [ test-file_1.encr ] identical to [ test-file_2.encr ]?

My tests so far showed that output files (ie. [ test-file_1.encr ] and [ test-file_2.encr ] will have, given the same encryption parameters, the same *size*, but they *are* different)

The reason for my question is because I'm trying to compare the SHA1 of encrypted files (where the private key isn't available on the server so I can't decrypt the file & calculate its hash)

Having the same output would solve the problem as I can then calculate the SHA1 of the encrypted file without any decryption needed.

Posted: 08/08/2012 18:30:41
by Ken Ivanov (Team)

Each time you encrypt a file, a unique random 'session' key is generated and used to encrypt the data. After that the session key itself is encrypted, either with a public key (if a keypair is used), or with a password. Those encryption procedures also use pseudorandom generator output in their work, introducing even more degree of randomness. That is, due to the way in which the data is encrypted, the resulting encrypted files will differ from each other even if the same input file is provided.

Please consider storing hashes of the source files next to the encrypted files if you need the ability to find out if they correspond to the same source files.



Topic viewed 1115 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!