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
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
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
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

 

 

 

ASCII / ANSI Secret Key in Symmetric Encryption

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Using an ASCII (or ANSI) secret key w/ symmetric encryption: AES, Blowfish, Twofish, RC2, 3DES, etc.

<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

'  A frequent support question goes something like this:
'  ------------------
'  I am not able to decrypt strings encrypted using
'  cryptix.jce.provider.key.RawSecretKey (Java) like I would normally do.

' The key generation is being done with the Rijndael algorithm (256-bit)
'  The AES encryption algorithm is "Rijndael/ECB/PKCS#5"

'  The 32 character source key I'm using is this:
'  1234567890123456789012345678912
' 
'  ------------------
'  The customer tries to call GenerateSecretKey to
'  convert the 32-character source key to a binary secret key,
'  but this is incorrect (in this case).  GenerateSecretKey
'  hashes a string of any length and produces binary hash output
'  that is of the appropriate size to be used as a secret key.

'  The telltale sign is that in this case, the string is the exact
'  length of the secret key.  32 ANSI characters = 256 bits.
'  Therefore, it is obvious that the bytes of the binary
'  secret key should be the exact ascii character values
'  of the string.

encKey = "1234567890123456789012345678912"

crypt.CryptAlgorithm = "aes"
'  Mode is "ecb" or "cbc"
crypt.CipherMode = "ecb"
crypt.KeyLength = 256

'  Call SetEncodedKey with "ascii" to tell the component
'  to use the ascii-bytes as the binary secret key.
'  Make sure you call this after setting the KeyLength.
crypt.SetEncodedKey encKey,"ascii"

crypt.EncodingMode = "base64"
text = "The quick brown fox jumped over the lazy dog."

'  Encrypt a string and return the binary encrypted data
'  in a base-64 encoded string.
encText = crypt.EncryptStringENC(text)

Response.Write encText & "<br>"

'  Decrypt and show the original string:
decryptedText = crypt.DecryptStringENC(encText)

Response.Write decryptedText & "<br>"
%>
</body>
</html>

 

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