Products » dgEncrypt User Guide

Method:  Cipher::EncryptStringHex

EncryptStringHex(PlainText)

The string given in the PlainText argument is encrypted, and the resulting cipher text is converted to a hexidecimal value before being returned as a string.
 
PlainText
The PlainText argument is the string to be encrypted.
 
Example:
<%
Dim strUserData
Dim strUserName
Dim strPassWord

strUserData = Request.Form("UserData")

If strUserData = "" Then
    Request.Redirect "error.asp"
End If

strUserName = Request.Form("UserName")

If strUserName = "" Then
    Request.Redirect "error.asp"
End If

strPassWord = Request.Form("PassWord")

If strPassWord = "" Then
    Request.Redirect "error.asp"
End If

Dim strCipherText
Dim objKey
Dim objCipher

' HKeyLocalMachine = &H80000002
Set objKey = Server.CreateObject("dgEncrypt.Key")
objKey.ReadKeyRegistry &H80000002, "SOFTWARE\Website", "ProfileKey"

Set objCipher = Server.CreateObject("dgEncrypt.Cipher")
objCipher.SetKey objKey
strCipherText = objCipher.EncryptStringHex(strPassWord)

Set objCipher = Nothing
Set objKey = Nothing

Dim blnResult
Dim objDoc

Set objDoc = Server.CreateObject("Msxml2.DOMDocument")
blnResult = objDoc.loadXML(strUserData)

If Not blnResult Then
    Set objDoc = Nothing
    Request.Redirect "error.asp"
End If

Dim objRoot
Dim objElement

Set objRoot = objDoc.documentElement

Set objElement = objRoot.selectSingleNode("UserName")
objElement.text = strUserName

Set objElement = objRoot.selectSingleNode("PassWord")
objElement.text = strCipherText

Response.ContentType = "text/xml"
Response.Write objDoc.xml

Set objElement = Nothing
Set objRoot = Nothing
Set objDoc = Nothing
%>