how to compare 2 encrypted files?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers how to compare 2 encrypted files?
# 1  
Old 03-14-2009
Bug how to compare 2 encrypted files?

I have 2 files :-
1) f1.txt and f2.txt.Both contain some text as -
Quote:
123456

2)Now I did :
Quote:
[...]#cmp f1.txt f2.txt
(OR)
[...]#diff f1.txt f2.txt
output: I got them to be equal.
3) I encrypted them using gpg and with the SAME paraphrase :-
Quote:
gpg -c --cipher-algo aes256 f1.txt

gpg -c --cipher-algo aes256 f2.txt
4)Now I did :
[...]#cmp f1.txt.gpg f2.txt.gpg
(OR)
[...]#diff f1.txt.gpg f2.txt.gpg
[/QUOTE]
output: I got them to be NOT equal.

Can you please tell me why?
My actual intension is to know how to compare any 2 encrypted files to know whether they contain the same text or not without DECRYPTING them!!!!
# 2  
Old 03-14-2009
That is a feature, not a bug. With many algorithms the data is encrypted block by block. And the previous encrypted data block is combined with the current plaintext data block as part of the encryption. To get the ball rolling, the algorithm generates a block a random data to combine with the first plain text data block. During decryption, this initial block of make believe encrypted data is discarded.

Now if the same data is encrypted with the same pass phrase, you can't tell by looking at the data. This is a good thing.

The only way to compare two encrypted data files is to decrypt them. If you don't know both passphrases, the contents of the files are none of your business.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Compare multiple files, and extract items that are common to ALL files only

I have this code awk 'NR==FNR{a=$1;next} a' file1 file2 which does what I need it to do, but for only two files. I want to make it so that I can have multiple files (for example 30) and the code will return only the items that are in every single one of those files and ignore the ones... (7 Replies)
Discussion started by: castrojc
7 Replies

2. Shell Programming and Scripting

Require compare command to compare 4 files

I have four files, I need to compare these files together. As such i know "sdiff and comm" commands but these commands compare 2 files together. If I use sdiff command then i have to compare each file with other which will increase the codes. Please suggest if you know some commands whcih can... (6 Replies)
Discussion started by: nehashine
6 Replies

3. Shell Programming and Scripting

Compare 2 folders to find several missing files among huge amounts of files.

Hi, all: I've got two folders, say, "folder1" and "folder2". Under each, there are thousands of files. It's quite obvious that there are some files missing in each. I just would like to find them. I believe this can be done by "diff" command. However, if I change the above question a... (1 Reply)
Discussion started by: jiapei100
1 Replies

4. Linux

Secured encrypted files via Linux

I need to encrypt a ".txt" file with password settings and it should decrypt the file automatoically when end user types correct password. Can some one help me on this. Thank you (3 Replies)
Discussion started by: rlmadhav
3 Replies

5. Shell Programming and Scripting

How to compare 2 files & get only few columns based on a condition related to both files?

Hiiiii friends I have 2 files which contains huge data & few lines of it are as shown below File1: b.dat(which has 21 columns) SSR 1976 8 12 13 10 44.00 39.0700 70.7800 7.0 0 0.00 0 2.78 0.00 0.00 0 0.00 2.78 0 NULL ISC 1976 8 12 22 32 37.39 36.2942 70.7338... (6 Replies)
Discussion started by: reva
6 Replies

6. Shell Programming and Scripting

compare files in two directories and output changed files to third directory

I have searched about 30 threads, a load of Google pages and cannot find what I am looking for. I have some of the parts but not the whole. I cannot seem to get the puzzle fit together. I have three folders, two of which contain different versions of multiple files, dist/file1.php dist/file2.php... (4 Replies)
Discussion started by: bkeep
4 Replies

7. UNIX for Dummies Questions & Answers

How to unzip multiple files (encrypted) in a directory.

Good day all. I want to unzip multiple files in a directory. Suppose there are two files: test.txt.zip and test1.txt.zip Using this command: unzip -o -P test*.zip results in the unzipping of the first file not second. It gives this error: Archive: test.txt.zip caution: filename not... (2 Replies)
Discussion started by: er_ashu
2 Replies

8. UNIX for Dummies Questions & Answers

encrypted files

Hi lads me again trying to get a wee bit fancy with my scripting anyway it dosn't seem to want to run (strange as it may seem) I encrypted a file renamed it and wrote another file that unencrypts it (it contains passwords) (and b4 anyone says I am doing this for my own reasons) In a... (3 Replies)
Discussion started by: w33man
3 Replies

9. UNIX for Advanced & Expert Users

executing encrypted files

Hi, Is there a way of executing encrypted files? I have encrpyted files using vi and crypt, but when I execute the encrypted file, it takes the contents literally (special characters, junk - encrpyted format). Kind Regards, Kawah (4 Replies)
Discussion started by: Kawah Cheung
4 Replies

10. UNIX for Dummies Questions & Answers

executing encrypted files

Hi, Is there a way of executing encrypted files? I have encrpyted files using vi and crypt, but when I execute the encrypted file, it takes the contents literally (special characters, junk - encrpyted format). Kind Regards, Kawah (1 Reply)
Discussion started by: Kawah Cheung
1 Replies
Login or Register to Ask a Question