Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PowerBuilder) Encrypt / Decrypt a File and Verify it has not ChangedDemonstrates how to encrypt and decrypt a file, and verify it has not changed.
integer li_rc integer li_Success oleobject loo_Crypt string ls_IvHex string ls_KeyHex string ls_DataFile string ls_OutFile string ls_OutFile2 oleobject loo_Fac integer li_BEqual // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Crypt = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt.ConnectToNewObject("Chilkat.Crypt2") if li_rc < 0 then destroy loo_Crypt MessageBox("Error","Connecting to COM object failed") return end if loo_Crypt.CryptAlgorithm = "aes" loo_Crypt.CipherMode = "cbc" loo_Crypt.KeyLength = 128 loo_Crypt.PaddingScheme = 0 ls_IvHex = "000102030405060708090A0B0C0D0E0F" loo_Crypt.SetEncodedIV(ls_IvHex,"hex") ls_KeyHex = "00010203040506071011121314151617" loo_Crypt.SetEncodedKey(ls_KeyHex,"hex") ls_DataFile = "qa_data/zips/HBIQ040615300005.ZIP" ls_OutFile = "qa_output/HBIQ040615300005.enc" ls_OutFile2 = "qa_output/HBIQ040615300005.ZIP" li_Success = loo_Crypt.CkEncryptFile(ls_DataFile,ls_OutFile) li_Success = loo_Crypt.CkDecryptFile(ls_OutFile,ls_OutFile2) loo_Fac = create oleobject // Use "Chilkat_9_5_0.FileAccess" for versions of Chilkat < 10.0.0 li_rc = loo_Fac.ConnectToNewObject("Chilkat.FileAccess") li_BEqual = loo_Fac.FileContentsEqual(ls_DataFile,ls_OutFile2) if li_BEqual <> 1 then Write-Debug "Decrypted file not equal to the original." else Write-Debug "Success." end if destroy loo_Crypt destroy loo_Fac |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.