(Classic ASP) Generate Salt in Hex or Base64 Format
Demonstrates how to generate a cryptographic salt value and get the result as hex or base64.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' In cryptography, a salt is random data that is used as an additional input to a one-way function that "hashes" data, a password or passphrase.
' Let's say we want to generate a 16-byte salt value..
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Prng")
set prng = Server.CreateObject("Chilkat.Prng")
saltHex = prng.GenRandom(16,"hex")
Response.Write "<pre>" & Server.HTMLEncode( "16-byte salt as hex: " & saltHex) & "</pre>"
saltBase64 = prng.GenRandom(16,"base64")
Response.Write "<pre>" & Server.HTMLEncode( "16-byte salt as base64: " & saltBase64) & "</pre>"
%>
</body>
</html>
|