Jump to content

Search the Community

Showing results for tags 'crypt variable'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. hi guys , is possible crypt a variable on the fly ? #include <Crypt.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #NoTrayIcon Local $sSourceRead = "helloworld" Local $sDestinationRead = (@ScriptDir &"\fattura_elettronica\FattureXML\B2C\risultato.txt") Local $sPasswordRead ="lamiapass" If StringStripWS($sSourceRead, $STR_STRIPALL) <> "" And StringStripWS($sDestinationRead, $STR_STRIPALL) <> "" And StringStripWS($sPasswordRead, $STR_STRIPALL) <> "" Then ; Check there is a file available to encrypt and a password has been set. If _Crypt_EncryptVariable($sSourceRead, $sDestinationRead, $sPasswordRead, $CALG_AES_256) Then ; Encrypt the file. ; MsgBox($MB_SYSTEMMODAL, "Success", "Operation succeeded.") Else Switch @error Case 30 MsgBox($MB_SYSTEMMODAL, "Error", "Failed to create the key.") Case 2 MsgBox($MB_SYSTEMMODAL, "Error", "Couldn't open the source file.") Case 3 MsgBox($MB_SYSTEMMODAL, "Error", "Couldn't open the destination file.") Case 400 Or 500 MsgBox($MB_SYSTEMMODAL, "Error", "Encryption error.") Case Else MsgBox($MB_SYSTEMMODAL, "Error", "Unexpected @error = " & @error) EndSwitch EndIf Else MsgBox($MB_SYSTEMMODAL, "Error", "Please ensure the relevant information has been entered correctly.") EndIf Func _Crypt_EncryptVariable($sSourceFile, $sDestinationFile, $vCryptKey, $iAlgID) Local $dTempData = 0, _ $hInFile = 0, $hOutFile = 0, _ $iError = 0, $iExtended = 0, $iFileSize = BinaryLen($sSourceFile), $iRead = 0, _ $bReturn = True _Crypt_Startup() If @error Then Return SetError(@error, @extended, -1) Do If $iAlgID <> $CALG_USERKEY Then $vCryptKey = _Crypt_DeriveKey($vCryptKey, $iAlgID) If @error Then $iError = @error $iExtended = @extended $bReturn = False ExitLoop EndIf EndIf $hInFile = StringToBinary($sSourceFile);, $FO_BINARY) If $hInFile = -1 Then $iError = 2 $iExtended = _WinAPI_GetLastError() $bReturn = False ExitLoop EndIf $hOutFile = FileOpen($sDestinationFile, $FO_OVERWRITE + $FO_CREATEPATH + $FO_BINARY) If $hOutFile = -1 Then $iError = 3 $iExtended = _WinAPI_GetLastError() $bReturn = False ExitLoop EndIf Do ;$dTempData = FileRead($hInFile, 1024 * 1024) $iRead += BinaryLen($hInFile) If $iRead = $iFileSize Then $dTempData = _Crypt_EncryptData($dTempData, $vCryptKey, $CALG_USERKEY, True) If @error Then $iError = @error + 400 $iExtended = @extended $bReturn = False EndIf FileWrite($hOutFile, $dTempData) ExitLoop 2 Else $dTempData = _Crypt_EncryptData($dTempData, $vCryptKey, $CALG_USERKEY, False) If @error Then $iError = @error + 500 $iExtended = @extended $bReturn = False ExitLoop 2 EndIf FileWrite($hOutFile, $dTempData) EndIf Until False Until True If $iAlgID <> $CALG_USERKEY Then _Crypt_DestroyKey($vCryptKey) _Crypt_Shutdown() ;If $hInFile <> -1 Then FileClose($hInFile) If $hOutFile <> -1 Then FileClose($hOutFile) Return SetError($iError, $iExtended, $bReturn) EndFunc ;==>_Crypt_EncryptFile when i try to decrypt not decript nothing
×
×
  • Create New...