Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

File Encryption / Decryption

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

File-to-file encryption in ASP using AES, Blowfish, RC2, ARC4, or 3DES.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")

success = crypt.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write "Crypt component unlock failed" & "<br>"

End If

crypt.CryptAlgorithm = "aes"
crypt.CipherMode = "cbc"
crypt.KeyLength = 128

'  16 bytes of key for 128-bit encryption.
key = "1234567890123456"

'  The IV is equal to the block size of the encryption algorithm.

iv = "1234567890123456"

'  Set the key.
crypt.SetEncodedKey key,"ascii"

'  Set the IV
crypt.SetEncodedIV iv,"ascii"

'  AES Encrypt the file (the file may be any size because it will
'  stream the file in/out.
success = crypt.CkEncryptFile("hamlet.xml","aesEncrypted.dat")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

'  AES Decrypt the file (the file may be any size because it will
'  stream the file in/out.
success = crypt.CkDecryptFile("aesEncrypted.dat","hamlet_aes.xml")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

Response.Write "AES File Encryption Success." & "<br>"

'  Now do 3DES file encryption:

'  To use Triple-DES, set the algorithm = "des",
'  and the key length = 168.
'  To use DES, set the key length = 56 bits.
crypt.CryptAlgorithm = "des"
crypt.CipherMode = "cbc"
crypt.KeyLength = 168

'  3DES Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","tripleDesEncrypted.dat")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

'  3DES Decrypt the file
success = crypt.CkDecryptFile("tripleDesEncrypted.dat","hamlet_3des.xml")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

Response.Write "3DES File Encryption Success." & "<br>"

'  Do Blowfish file encryption:

'  To use Blowfish, set the algorithm = "blowfish2".
'  The original Chilkat "blowfish" implementation outputs
'  4321 swapped bytes.  "blowfish2" output is in the correct
'  byte order.
crypt.CryptAlgorithm = "blowfish2"
crypt.CipherMode = "cbc"
crypt.KeyLength = 128

'  Blowfish Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","blowfishEncrypted.dat")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

'  Blowfish Decrypt the file
success = crypt.CkDecryptFile("blowfishEncrypted.dat","hamlet_blowfish.xml")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

Response.Write "Blowfish File Encryption Success." & "<br>"

'  Do RC2 file encryption:

'  To use RC2, set the algorithm = "rc2".
'  Also, set the Rc2EffectiveKeyLength property.
crypt.CryptAlgorithm = "rc2"
crypt.CipherMode = "cbc"
'  Key length and effective key length should range
'  from 8 to 1024 bits.
crypt.KeyLength = 128
crypt.Rc2EffectiveKeyLength = 128

'  RC2 Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","rc2Encrypted.dat")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

'  RC2 Decrypt the file
success = crypt.CkDecryptFile("rc2Encrypted.dat","hamlet_rc2.xml")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

Response.Write "RC2 File Encryption Success." & "<br>"

'  Do ARC4 file encryption:

'  To use ARC4, set the algorithm = "arc4".
crypt.CryptAlgorithm = "arc4"
crypt.KeyLength = 128

'  ARC4 Encrypt the file
success = crypt.CkEncryptFile("hamlet.xml","arc4Encrypted.dat")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

'  ARC4 Decrypt the file
success = crypt.CkDecryptFile("arc4Encrypted.dat","hamlet_arc4.xml")
If (success <> 1) Then
    Response.Write crypt.LastErrorText & "<br>"

End If

Response.Write "ARC4 File Encryption Success." & "<br>"


%>
</body>
</html>

 

© 2000-2026 Chilkat Software, Inc. All Rights Reserved.