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.
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.
Joined: Apr 09, 2009
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 !
Joined: Oct 14, 2008
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.