Jump to content

File Crypt & Decrypt functions non working correctly with large files


Efo74
 Share

Recommended Posts

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:

Link to comment
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

Link to comment
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

Link to comment
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

Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...