Hello, How can i get boolean value in C++ for CkEncryptFile and get if file is already encrypted? Thanks.
I don't think you can - when a file is encrypted it takes on the appearance of random (or near random) bytes. That said, you could create your own file format that has either a leading or trailing identifier that identifies it as one of your encrypted files, and then detect that identifier to determine if the file is already encrypted before encrypting it again. Before decrypting, you should strip the identifier or you will get incorrect results.
Unencrypted file = THISISAFILE
Encrypted file = aj09243hijwbg
Encrypted file with header = MYENCRYPTEDFORMAT_aj09243hijwbg
User attempts to encrypt a file - if you detect MYENCRYPTEDFORMAT_ at the start of the file, then refuse to encrypt.
User attempts to decrypt a file - if you detect MYENCRYPTEDFORMAT_ at the start of the file, strip it then decrypt the remaining bytes. If you don't detect the header, then alert the user that the file is no encrypted and refuse to decrypt.
i think you mean same think what i made, i made encrypted file (encrypt filename+ext) and add ext .locked. when i decrypting, then i decrypt only string without .locked and make if where i list files only with locked ext and this works :) thanks.
but one last question, how can i check or if its possible, then how can i check when user enter incorrect password for decryption. for example i encrypt file with
crypto->CryptAlgorithm = "aes"; crypto->CipherMode = "ecb"; crypto->EncodingMode = "hex"; crypto->KeyLength = 256; crypto->SetSecretKeyViaPassword("heslo");
and user decrypt with for example crypto->CryptAlgorithm = "aes"; crypto->CipherMode = "ecb"; crypto->EncodingMode = "hex"; crypto->KeyLength = 256; crypto->SetSecretKeyViaPassword("hESlo");
its possible? thanks :)