Encryption Decryption Problem in Web Services
-
Hi, I am using the following code to decrypt an array of bytes: DESCryptoServiceProvider des=new DESCryptoServiceProvider(); des.BlockSize=blockSize; des.Key=kDESKey; des.KeySize=64; des.Padding=PaddingMode.PKCS7; des.Mode=CipherMode.ECB; ICryptoTransform cryptoTransform=des.CreateDecryptor(); MemoryStream mem=new MemoryStream(cipherTextBytes); CryptoStream cryptoStream=new CryptoStream(mem,cryptoTransform,CryptoStreamMode.Read); byte[] outputBuffer=new byte[cipherTextBytes.Length]; cryptoStream.Read(outputBuffer,0,outputBuffer.Length); mem.Close(); cryptoStream.Close(); return outputBuffer; But the problem is that when i call Read of the cryptoStream, i get System.Cryptography.CryptographicException with the message of "Bad Data". Basically above code is the part of a web service. I am not concerned with the above code. I just want to provide some security feature to my web service. If it can be done through some other easy way, that's also welcome. Please guide me in this regard... Wasif Ehsan.