Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode 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
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
MS Storage Providers
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

 

 

 

AES Encryption to Match PHP's Mcrypt Extension

Demonstrates how to match AES encryption results with PHP's mcrypt extension.

Please refer to this discussion about PHP AES Encryption. The code here matches the PHP mcrypt results on that page.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<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

'  AES is also known as Rijndael.
crypt.CryptAlgorithm = "aes"

'  CipherMode may be "ecb" or "cbc"
crypt.CipherMode = "cbc"

'  KeyLength may be 128, 192, 256
crypt.KeyLength = 256

'  Pad with NULL bytes (PHP pads with NULL bytes)
crypt.PaddingScheme = 3

'  EncodingMode specifies the encoding of the output for
'  encryption, and the input for decryption.
'  It may be "hex", "url", "base64", or "quoted-printable".
crypt.EncodingMode = "hex"

ivAscii = "1234567890123456"
crypt.SetEncodedIV ivAscii,"ascii"

'  The secret key must equal the size of the key.  For
'  256-bit encryption, the binary secret key is 32 bytes.
'  For 128-bit encryption, the binary secret key is 16 bytes.
keyAscii = "12345678901234561234567890123456"
crypt.SetEncodedKey keyAscii,"ascii"

plainText = "The quick brown fox jumped over the lazy dog"

cipherText = crypt.EncryptStringENC(plainText)
Response.Write cipherText & "<br>"

'  Do 128-bit AES encryption:
crypt.KeyLength = 128
keyAscii = "1234567890123456"
crypt.SetEncodedKey keyAscii,"ascii"

cipherText = crypt.EncryptStringENC(plainText)
Response.Write cipherText & "<br>"

'  -------
'  Results
'  -------
'  You may use these as test vectors for testing your AES implementations...
' 
'  ------------------------
'  256-bit key, CBC mode
'  ------------------------
'  IV = '1234567890123456' 
'   (hex: 31323334353637383930313233343536)
'  Key = '12345678901234561234567890123456' 
'   (hex: 3132333435363738393031323334353631323334353637383930313233343536)
'  PlainText:
'   'The quick brown fox jumped over the lazy dog'
	// CipherText(hex):
'   2fddc3abec692e1572d9b7d629172a05caf230bc7c8fd2d26ccfd65f9c54526984f7cb1c4326ef058cd7bee3967299e3

' 
'  ------------------------
'  128-bit key, CBC mode
'  ------------------------
'  IV = '1234567890123456' 
'   (hex: 31323334353637383930313233343536)
'  Key = '1234567890123456' 
'   (hex: 31323334353637383930313233343536)
'  PlainText:
'   'The quick brown fox jumped over the lazy dog'
	// CipherText(hex):
'   f78176ae8dfe84578529208d30f446bbb29a64dc388b5c0b63140a4f316b3f341fe7d3b1a3cc5113c81ef8dd714a1c99

%>
</body>
</html>

 

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