Jump to content

Regarding crypt include file


Recommended Posts

I seem to be having a problem with the encrypt function.

The include file is #Include <Crypt.au3>

My code is below and what it seems is that I run the encrypt function once, it encrypts the file correctly, I run it again exactly the same function and it decrypts.

I'm thinking its a problem with the include as my code is very basic and I'm simply using the encrypt function. Makes it difficult to encrypt and decrypt properly.

Anyone know if running the _Crypt_EncryptFile function twice over the same file with same algorithm and password/crypt key unencrypts the file?

func encryptfile($sSourceFile, $sDestinationFile,$vpassword,$vfiletype)

    $sDestinationFile=$vpath&"tmp123.txt"

If FileExists($sSourceFile) Then
Else
    msgbox(0,"EON Error Message","Can't find "&$vfiletype&". Looking for "&$vpath&$vfilename)
    $errmessen="true"
EndIf

if $vpassword<>"" Then
Else
    msgbox(0,"EON Error Message","No password found for "&$vfiletype&" .")
    $errmessen="true"
EndIf

if $errmessen<>"true" Then
$vCryptKey=_Crypt_DeriveKey($vPassword,$CALG_RC4 )
_Crypt_EncryptFile($sSourceFile, $sDestinationFile, $vCryptKey, $iALG_ID)
_Crypt_DestroyKey( $vCryptKey)
FileCopy($sDestinationFile, $sSourceFile,1)
_SecureFileDelete($sDestinationFile)
Else
    msgbox(0,"EON Error Message","Error saving file. Cancelling "&$vfiletype&" save.")
endif

EndFunc

Thanks,

John

Edited by johnjamie
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...