Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3/4 Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(Tcl) Twofish CFB Mode EncryptionDemonstrates how to encrypt using Twofish CFB (Cipher Feedback) mode.
load ./chilkat.dll set crypt [new_CkCrypt2] set success [CkCrypt2_UnlockComponent $crypt "Anything for 30-day trial"] if {[expr $success != 1]} then { puts [CkCrypt2_lastErrorText $crypt] delete_CkCrypt2 $crypt exit } CkCrypt2_put_CryptAlgorithm $crypt "twofish" CkCrypt2_put_CipherMode $crypt "cfb" CkCrypt2_put_KeyLength $crypt 256 # EncodingMode specifies the encoding of the output for # encryption, and the input for decryption. # It may be "hex", "url", "base64", "quoted-printable", or many other choices. CkCrypt2_put_EncodingMode $crypt "hex" set ivHex "000102030405060708090A0B0C0D0E0F" CkCrypt2_SetEncodedIV $crypt $ivHex "hex" # The secret key must equal the size of the key. For # 256-bit encryption, the binary secret key is 32 bytes. set keyHex "603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4" CkCrypt2_SetEncodedKey $crypt $keyHex "hex" # Encrypt a string... set encStr [CkCrypt2_encryptStringENC $crypt "We must face the fact that the preservation of individual freedom is incompatible with a full satisfaction of our views of distributive justice. -- Friedrich Hayek"] puts "$encStr" set decrypt [new_CkCrypt2] CkCrypt2_put_CryptAlgorithm $decrypt "twofish" CkCrypt2_put_CipherMode $decrypt "cfb" CkCrypt2_put_KeyLength $decrypt 256 CkCrypt2_put_EncodingMode $decrypt "hex" CkCrypt2_SetEncodedIV $decrypt $ivHex "hex" CkCrypt2_SetEncodedKey $decrypt $keyHex "hex" # Now decrypt: set decStr [CkCrypt2_decryptStringENC $decrypt $encStr] puts "$decStr" delete_CkCrypt2 $crypt delete_CkCrypt2 $decrypt |
© 2000-2016 Chilkat Software, Inc. All Rights Reserved.