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
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

 

 

 

ARC4 Encryption (ARCFOUR)

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Demonstrates simple ARC4 encryption to match some simple test vectors published by Wikipedia. ARC4 is a fast stream cipher supporting key lengths from 8 to 2048 bits (i.e. from 1 to 256 bytes). It is not a block cipher, so there is no padding, no modes, and no initialization vector.

<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 Server.HtmlEncode("Crypt component unlock failed") & "<br>"

End If

'  Set the encryption algorithm to ARC4:
crypt.CryptAlgorithm = "arc4"

'  We want the encrypted output to be a hex-encoded string.
crypt.EncodingMode = "hex"

'  Encrypt some test vectors from Wikipedia:

'  The key length (in bits) is equal to the number of us-ascii
'  bytes in our key string * 8.

' ARC4( "Key", "Plaintext" ) == BBF316E8D940AF0AD3
crypt.KeyLength = 24
crypt.SetEncodedKey "Key","ascii"
cipherText = crypt.EncryptStringENC("Plaintext")
Response.Write Server.HtmlEncode(cipherText) & "<br>"
plainText = crypt.DecryptStringENC(cipherText)
Response.Write Server.HtmlEncode(plainText) & "<br>"

' ARC4( "Wiki", "pedia" ) == 1021BF0420
crypt.KeyLength = 32
crypt.SetEncodedKey "Wiki","ascii"
cipherText = crypt.EncryptStringENC("pedia")
Response.Write Server.HtmlEncode(cipherText) & "<br>"
plainText = crypt.DecryptStringENC(cipherText)
Response.Write Server.HtmlEncode(plainText) & "<br>"

' ARC4( "Secret", "Attack at dawn" ) == 45A01F645FC35B383552544B9BF5
crypt.KeyLength = 48
crypt.SetEncodedKey "Secret","ascii"
cipherText = crypt.EncryptStringENC("Attack at dawn")
Response.Write Server.HtmlEncode(cipherText) & "<br>"
plainText = crypt.DecryptStringENC(cipherText)
Response.Write Server.HtmlEncode(plainText) & "<br>"

'  Note: The call to SetEncodedKey serves to set the key
'  to the us-ascii bytes of the string.

%>
</body>
</html>

 

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