Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
|
AES Encryption / Decryption in ASP Use 256-bit AES encryption to encrypt a string and then either Base64 encode it, Hex encode it (hexidecimalize), or encode to quoted-printable. Reverse the operation to get the original string back. <%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>AES Interop Example</TITLE>
</HEAD>
<BODY bgcolor="#FFFFFF">
<%
' Create the Chilkat object.
set aes = Server.CreateObject("AesInterop.AesInterop")
' Get a 30-day trial unlock code
aes.UnlockComponent "unlockCode"
' The password must be the same for decryption.
aes.PassPhrase = "MySecretPassword"
' Use 256-bit encryption
aes.KeyLength = 256
' Data to encrypt
myData = "Chilkat Software, Inc."
%>
<h2><font color="#330099">1. AES Encrypt a String: "Chilkat Software, Inc."</font></h2>
<h3>AES Encrypted and then Base64 Encoded:</h3>
<%
strBase64 = aes.EncodeToBase64(aes.Encrypt(myData))
Response.write strBase64
%>
<br><br>
<h3>AES Encrypted and then Hex-Encoded:</h3>
<%
strHex = aes.EncodeToHex(aes.Encrypt(myData))
Response.write strHex
%>
<br><br>
<h3>AES Encrypted and then Converted to Quoted-Printable:</h3>
<%
strQP = aes.EncodeToQP(aes.Encrypt(myData))
Response.write strQP
%>
<br><br>
<h2><font color="#330099">2. Decrypt Each String</font></h2>
<h3>Decode from Base64 and AES Decrypt:</h3>
<%
str = aes.Decrypt(aes.DecodeFromBase64(strBase64))
Response.write str
%>
<h3>Hex-Decode and then AES Decrypt:</h3>
<%
str = aes.Decrypt(aes.DecodeFromHex(strHex))
Response.write str
%>
<h3>QP-Decode and then AES Decrypt:</h3>
<%
str = aes.Decrypt(aes.DecodeFromQP(strQP))
Response.write str
%>
</BODY>
</HTML>
ASP Tutorial, ASP Script, ASP Application, ASP Software, ASP Code, ASP
Programming, ASP Component, Free ASP Script, ASP Email, ASP Help, ASP
Example, ASP Source Code, ASP Developer, ASP Mail, ASP XML, ASP Sample
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.