开发者

How to resolve error while implementing DES encrypt/decrypt in asp.net?

I am trying to implement DES encryption in asp.net application from the given link:

DES encrypt/开发者_开发知识库decrypt

as per given code its working fine but if i add one more character in bytes variable its throwing exception

static byte[] bytes = ASCIIEncoding.ASCII.GetBytes("ZeroCool"); //Working fine
static byte[] bytes = ASCIIEncoding.ASCII.GetBytes("ZeroCoola"); //throwing exception

How to resolve error while implementing DES encrypt/decrypt in asp.net?

Anybody have idea how to resolve this one?

Is there any limit of 8 character in DES encryption?

Thanks


DES supports 56-bit keys, so you can't add another one. Actually 56 bits = 7 bytes, so I supposed "Zerocool" worked because all the characters are standard ASCII, and those only take 7 bits each.

That being said...

  1. DES is a really old cipher. A 56-bit key can be easily bruteforced by a modern home computer. You should be using ciphers that support larger keys, like AES.

  2. I read this at the end of the article:

Using DES, you can encrypt or decrypt users' passwords or something else, and you can delve into the algorithm if you like.

Which has got me concerned. Passwords should never be encrypted. On the basis of that statement alone, I would disregard the entire article as useless.


The line :

static byte[] bytes = ASCIIEncoding.ASCII.GetBytes("ZeroCool");

Is not a byte array of the string you're trying to encrypt, it's the key for the encryption process.

It is used in conjunction with the initialization vector (IV) in setting up the encryption.

writer.Write(originalString);

Is where you should be looking if you're quering the encryption output.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜