TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Administrator
Tech Writer
2.2k
1.5m
DES produces bad data over 50% of the time
Apr 7 2003 2:09 PM
I am receiving a Crypto BAD DATA exception about 50% of the time I try to read back encrypted data. I am interfacing with Tucows registrar servers, and they require me to connect with encrypted data using DES. Here is the code I have. Like I said, it works ... partially........90% of the time the login packets go through correctly. 20% of the time the following packet successfully encrypts. This is in my send data method, so this is done per packet. I was curious why I was receiving their invalid data error, until I made a function that verified all outgoing data by trying to decrypt it. Instead of receiving an error message from Tucows, it crashes with the CryptoException : Bad Data. As far as I can tell, I am not doing anything wrong, can somebody shine some light on this for me? Thanks! System.IO.MemoryStream ms = new System.IO.MemoryStream(); desProvider.GenerateIV(); byte [] realIV = desProvider.IV; desProvider.Mode = CipherMode.CBC; desProvider.Padding = PaddingMode.PKCS7; ICryptoTransform encrypto = this.desProvider.CreateEncryptor(key,desProvider.IV); // create Crypto Stream that transforms a stream using the encryption CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write); // write out encrypted content into MemoryStream cs.Write(data, 0, data.Length); cs.FlushFinalBlock(); // get the output and trim the '\0' bytes byte[] bytOut = ms.GetBuffer(); int i = 0; for (i = 0; i < bytOut.Length; i++) if (bytOut[i] == 0) break; data = bytOut;
Reply
Answers (
1
)
Run process Remotely
SecurityException