Hi zusammen, ich habe folgenden Code der in einer Windowsforms Application problemlos funktioniert.
Dim encryptedBytes() As Byte = Convert.FromBase64String(encryptedtext)
Dim ms As New System.IO.MemoryStream
Dim decStream As New CryptoStream(ms, _
TripleDes.CreateDecryptor(), _
System.Security.Cryptography.CryptoStreamMode.Write)
decStream.Write(encryptedBytes, 0, encryptedBytes.Length)
>>> decStream.FlushFinalBlock()
Return System.Text.Encoding.Unicode.GetString(ms.ToArray)
Rufe ich mit dem selben String die Routine in meinem WCF Service auf, bekomme ich bei FlushFinalBlock einen Fehler.
Ungültige Daten
System.Security.Cryptography.CryptographicException wurde nicht von Benutzercode behandelt.
Message=Ungültige Daten
Source=mscorlib
StackTrace:
bei System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
bei System.Security.Cryptography.Utils._DecryptData(SafeKeyHandle hKey, Byte[] data, Int32 ib, Int32 cb, Byte[]& outputBuffer, Int32 outputOffset, PaddingMode PaddingMode, Boolean fDone)
bei System.Security.Cryptography.CryptoAPITransform.TransformFinalBlock(Byte[] inputBuffer, Int32 inputOffset, Int32 inputCount)
bei System.Security.Cryptography.CryptoStream.FlushFinalBlock()
Woran kann das liegen?