(Classic ASP) Base64 Encode/Decode a String
Classic ASP example to base-64 encode and decode a string.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData")
set bd = Server.CreateObject("Chilkat.BinData")
s = "A friend called me up the other day and talked about investing in a dot-com that sells lobsters. Internet lobsters. Where will this end? --Donald Trump"
success = bd.AppendString(s,"utf-8")
strBase64 = bd.GetEncoded("base64")
Response.Write "<pre>" & Server.HTMLEncode( strBase64) & "</pre>"
' To decode:
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData")
set bd2 = Server.CreateObject("Chilkat.BinData")
success = bd2.AppendEncoded(strBase64,"base64")
decoded = bd2.GetString("utf-8")
Response.Write "<pre>" & Server.HTMLEncode( decoded) & "</pre>"
%>
</body>
</html>
|