aspose file tools*
The moose likes Java in General and the fly likes Is file encrypted Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Is file encrypted" Watch "Is file encrypted" New topic
Author

Is file encrypted

Manju Krishna
Ranch Hand

Joined: Apr 09, 2009
Posts: 48
    
    1
Hello All,

Is there any way to find if the particular file instance is encrypted or not.
One solution what I had was to decrypt and check if the exception is thrown else continue. But it would be an overhead for users not using encryption.

Please help on alternatives . Thanks !
akash shrimali
Ranch Hand

Joined: Jul 28, 2010
Posts: 45
there is no alternative to this one according to me, the only option which you have tried is totally correct !!
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
How did you "decrypt"? There is an endless variety of ciphers, you can't possibly try them all, particularly not if you don't have the keys. And even if you tried just one, and got no exception, how would you decide that the result is not encrypted further? It might be a binary file in cleartext in a format you don't know, or it might be an encrypted file. So, there is no way to know for sure unless you have more information about the file that you didn't mention.
Manju Krishna
Ranch Hand

Joined: Apr 09, 2009
Posts: 48
    
    1
I have generated a jks file and using that for encrypt and decrypt.!
Moreover I am also using a third party helper called bouncycastle

So when i have encrypted with those keytool and password I try to decrypt using the same !
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
OK, so you know the algorithm and you know the key. That makes it quite a bit easier.

But there's no way to tell in general whether a random binary file is encrypted or not.
Manju Krishna
Ranch Hand

Joined: Apr 09, 2009
Posts: 48
    
    1
Thanks for all your replies!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Is file encrypted