As it appeared to be replacing encrypt with decrypt did not help the problem
You should also change padding setting in coldfusion. See the reverse code below:
.NET
<html>
<head>
</head>
<body>
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Security.Cryptography" %>
<script runat=server language=vbscript>
Public Class Encryption64
' Use DES CryptoService with Private key pair
Private key() As Byte = {} ' we are going to pass in the key portion in our method calls
Private IV() As Byte = {80,108,67,75,101,121,87,83}
Public Function DecryptFromBase64String(ByVal stringToDecrypt As String, ByVal sEncryptionKey As String) As String
Dim inputByteArray(stringToDecrypt.Length) As Byte
' Note: The DES CryptoService only accepts certain key byte lengths
' We are going to make things easy by insisting on an 8 byte legal key length
Try
key = System.Text.Encoding.UTF8.GetBytes(Left(sEncryptionKey, 8))
Dim des As New DESCryptoServiceProvider()
' we have a base 64 encoded string so first must decode to regular unencoded (encrypted) string
inputByteArray = Convert.FromBase64String(stringToDecrypt)
' now decrypt the regular string
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateDecryptor(key, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
Dim encoding As System.Text.Encoding = System.Text.Encoding.UTF8
Return encoding.GetString(ms.ToArray())
Catch e As Exception
Return e.Message
End Try
End Function
Public Function EncryptToBase64String(ByVal stringToEncrypt As String, ByVal SEncryptionKey As String) As String
Try
key = System.Text.Encoding.UTF8.GetBytes(Left(SEncryptionKey, 8))
Dim des As New DESCryptoServiceProvider()
' convert our input string to a byte array
Dim inputByteArray() As Byte = Encoding.UTF8.GetBytes(stringToEncrypt)
'now encrypt the bytearray
Dim ms As New MemoryStream()
Dim cs As New CryptoStream(ms, des.CreateEncryptor(key, IV), CryptoStreamMode.Write)
cs.Write(inputByteArray, 0, inputByteArray.Length)
cs.FlushFinalBlock()
' now return the byte array as a "safe for XMLDOM" Base64 String
Return Convert.ToBase64String(ms.ToArray())
Catch e As Exception
Return e.Message
End Try
End Function
End Class
Function CleanString(ByVal str As String) As String
Dim clean As String
' clean the pluses and forward slashes that appear in the BASE64encoding
clean = str.replace("+", "%2B")
clean = clean.replace("/", "%2F")
Return clean
End Function
Function DecryptData()
Dim enc As New Encryption64
Dim base64encr As String = Request.QueryString("Q")
Dim DecryptedData As String = enc.DecryptFromBase64String(base64encr, "ABCDEFGH")
Return DecryptedData
End Function
</script>
<%=DecryptData()%>
</body>
</html>
ColdFusion
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body>
<cfscript>
function CleanString(str) {
str = replace(str, "+", "%2B", "all");
str = replace(str, "/", "%2F", "all");
return str;
}
theKey = ToBase64("ABCDEFGH");
Vector = ToBase64("PlCKeyWS");
baseVector = ToBinary(Vector);
parameters = "Name=Valentin&Group=STU&DateTime=123014062007&URL=http://www.pymblelc.nsw.edu.au/PLC/pymble-members/sport--pymble/sports--pymble_home.cfm";
remain = len(parameters) MOD 8;
encrypted = encrypt(parameters, theKey, "DES/CBC/PKCS5Padding", "BASE64", baseVector);
decrypted = decrypt(encrypted, theKey, "DES/CBC/PKCS5Padding", "BASE64", baseVector);
</cfscript>
<cfoutput>
Click <a href="http://localhost:8080/plc2.aspx?Q=#CleanString(encrypted)#">here</a> to go to a .NET site<br />
#encrypted#<br />
#decrypted#
</cfoutput>
</body>
</html>