Sign in to follow this  
Followers 0
Efo74

File Crypt & Decrypt functions non working correctly with large files

11 posts in this topic

Hello,

today I have test the functions _Crypt_EncryptFile and _Crypt_DecryptFile also with built in autoit example script.

I have use $CALG_RC4 algorithm and pdf file of 4mb dimension.

The result in encrypt/decrypt file come unreadable. The dimesion of original pdf and the destination is the same.

Is there a solution. Is a know bug ?. Is my mistake ?

If I use a small pdf file (19k) , all is working fine.

Thank you for support. :ILA3:


:rolleyes:

Share this post


Link to post
Share on other sites



Post your code, because I just encrypted and decrypted a 19MB PDF and it opened just fine after decrypting it. I used the example scripts from _Crypt_EncryptFile and _Crypt_DecryptFile.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

The code is the autoit example of functions _Crypt_EncryptFile and _Crypt_DecryptFile. PDF file 3,8Mb, autoit 3.3.12.0, Windows 8.1 x64. algorithm is RC4. Now i will test other algorithm.


:rolleyes:

Share this post


Link to post
Share on other sites

3DES algorithm is working fine


:rolleyes:

Share this post


Link to post
Share on other sites

Do you get an error when you try to encrypt or decrypt the file? Like I said, on my computer (Windows 7 x64) it's working fine for me on a much larger file than you're using, with the RC4 algorithm.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

No, there are no errors.


:rolleyes:

Share this post


Link to post
Share on other sites

I confirm. I have test same example scripts and the same pdf to one Virtual Machine with Windows 7 x64 , algorithm RC4 is working fine.


:rolleyes:

Share this post


Link to post
Share on other sites

The problem is Windows 8.1 ?


:rolleyes:

Share this post


Link to post
Share on other sites

I'm not sure if it's related or not, but by default Windows 8+ turns off the ability to use RC4 for TLS in Internet Explorer. Like I said I don't know if disabling the ability to use it in IE will disable the ability to use it in the CryptEncrypt API as well, I'm going to guess that it does.

BTW, RC4 is not at all a secure algorithm to use so even if you can't use it, you're probably better off without it. 


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Thank you very much for your support, I have change my script and now I will use 3DES. :bye:


:rolleyes:

Share this post


Link to post
Share on other sites

I can confirm that something is going on with Win 8.1. The same executable worked no problem on Server 2008.

RC4 is not disabled, whatever BrewMan means with that. Decryption works fine, and encryption works up to the last part encrypted with $bFinal = True. This is easily seen by running a text file through the examples (only last MB is corrupted).

On a whim I changed

$aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptEncrypt", "handle", $vCryptKey, "handle", 0, "bool", $bFinal, "dword", 0, "ptr", 0, _

to

$aRet = DllCall(__Crypt_DllHandle(), "bool", "CryptEncrypt", "handle", $vCryptKey, "handle", 0, "bool", False, "dword", 0, "ptr", 0, _

and now _Crypt_EncryptFile seems fine. I don't know if that's the proper way to do this so do with that as you want, but something needs to be done with _Crypt_EncryptData as returning success on bad data is only going to lead to tears.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0