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

 

 

 

Duplicate Java's PBEWithMD5AndDES

Demonstrate's how to duplicate Java's PBEWithMD5AndDES.

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 "<pre>" & Server.HTMLEncode(crypt.LastErrorText) & "</pre>"

End If

crypt.CryptAlgorithm = "pbes1"
crypt.PbesPassword = "secret"

crypt.PbesAlgorithm = "des"
crypt.KeyLength = 64

'  The salt for PBKDF1 is always 8 bytes:
crypt.SetEncodedSalt "C773218C7EC8EE99","hex"

crypt.IterationCount = 20

'  A hash algorithm needs to be set for PBES1:
crypt.HashAlgorithm = "md5"

'  Indicate that the encrypted bytes should be returned
'  as a hex string:
crypt.EncodingMode = "hex"

plainText = "This is another example"

encryptedText = crypt.EncryptStringENC(plainText)

'  The output should be: E729548140D20B14E9140F832A7E980AA449A84B295C75CE
Response.Write "<pre>" & Server.HTMLEncode( encryptedText) & "</pre>"

'  Now decrypt:
decryptedText = crypt.DecryptStringENC(encryptedText)

Response.Write "<pre>" & Server.HTMLEncode( decryptedText) & "</pre>"

'  ----------------------------------------------------------------
'  ----------------------------------------------------------------
'  
The code above duplicates this Java JCE example:

	public static void main(String args[]) throws Exception
	{
	    PBEKeySpec pbeKeySpec;
	    PBEParameterSpec pbeParamSpec;
	    SecretKeyFactory keyFac;

	    // Salt
	    byte[] salt = {
		(byte)0xc7, (byte)0x73, (byte)0x21, (byte)0x8c,
		(byte)0x7e, (byte)0xc8, (byte)0xee, (byte)0x99
	    };

	    // Iteration count
	    int count = 20;

	    // Create PBE parameter set
	    pbeParamSpec = new PBEParameterSpec(salt, count);

	    String password = "secret";
	    pbeKeySpec = new PBEKeySpec(password.toCharArray());
	    keyFac = SecretKeyFactory.getInstance("PBEWithMD5AndDES");
	    SecretKey pbeKey = keyFac.generateSecret(pbeKeySpec);

	    // Create PBE Cipher
	    Cipher pbeCipher = Cipher.getInstance("PBEWithMD5AndDES");

	    // Initialize PBE Cipher with key and parameters
	    pbeCipher.init(Cipher.ENCRYPT_MODE, pbeKey, pbeParamSpec);

	    // Our cleartext
	    byte[] cleartext = "This is another example".getBytes();
	    
	    // Encrypt the cleartext
	    byte[] ciphertext = pbeCipher.doFinal(cleartext);
	    
     	System.out.print("ciphertext: ");
        System.out.println(toHex(ciphertext));
	}

%>
</body>
</html>

 

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