Crypt.Decrypt
Crypt.Decrypt
This method decrypts data encrypted with the Encrypt method, using the same key.
Syntax
Function Crypt.Decrypt(rawData) As String
Parameters
- rawData
The data to be decrypted, in the form of a string.
Return values
Data decrypted using the Microsoft® .NET Passport participant key for the current site, as a string.
Example
The following Microsoft Visual Basic Scripting Edition (VBScript) example shows the Compress, Encrypt, Decrypt, and Decompress methods can be used together for transmittal of an encrypted string. In this example, a string is compressed, encrypted, decrypted, and finally decompressed. The displayed string is the same as the original string.
<%@ Language=VBScript %> <HTML> <HEAD><TITLE>Exercise</TITLE></HEAD> <% 'Create a Passport object Dim oMgr Set oMgr = Server.CreateObject("Passport.Manager") Dim oCrypt Set oCrypt = Server.CreateObject("Passport.Crypt") Dim thisURL thisURL="https://" & Request.ServerVariables("SERVER_NAME") & Request.ServerVariables("SCRIPT_NAME") If oMgr.IsAuthenticated(3600,False,False) then 'Set the sign-out URL - return to the Default.asp ruURL = Server.URLEncode ("https://" & Request.ServerVariables("SERVER_NAME") & "/Brief/default.asp") Else 'Set the sign-in URL - stay on this page ruURL = thisURL End if Response.Write ("<DIV Style = 'position:absolute; right:50px'>" & oMgr.LogoTag2(ruURL,3600,False,"nada",1033,False) & "</DIV>") If oMgr.IsAuthenticated(3600,False,False) Then Response.Write ("You are authenticated") 'Define and display original string Dim mystring mystring = "This is a string to be compressed, encrypted, transmitted, decrypted, and finally decompressed." Response.Write ("<br>Original string: " & mystring) 'Compress and Encrypt the string mystring = oCrypt.Compress(mystring) mystring = oCrypt.Encrypt(mystring) 'This is where the encrypted string would be transmitted over the wire 'Decrypt, Decompress, and display the string mystring = oCrypt.Decrypt(mystring) mystring = oCrypt.Decompress(mystring) Response.Write ("<br>Reconstructed string: " & mystring) Else Response.Write ("<br>You have not been authenticated within the last hour. Please sign in or exit.") End If %> </HTML>
The preceding example results in an page that looks similar to the following;
Original string: This is a string to be compressed, encrypted, transmitted, decrypted, and finally decompressed. Reconstructed string: This is a string to be compressed, encrypted, transmitted, decrypted, and finally decompressed.
Remarks
After the Encrypt method is executed, the Decrypt method must be called to make the data readable.
Note An empty (NULL) input returns a NULL. Attempting to decrypt a blob larger than 5498 bytes will fail. The Encrypt method is limited to a blob size of 2045 bytes and will also fail if attempting to encrypt that amount of data.
See Also
Passport Crypt Object | Crypt.Compress | Crypt.Decompress | Crypt.Encrypt