1

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

enter image description here

Anybody have idea how to resolve this one?

Is there any limit of 8 character in DES encryption?

Thanks

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

just a matter of interest, what is your viewpoint on triple des?
1

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.

2 Comments

i.e. key should not be more than 8 character long.Am i right?
@Sukhi: Almost right. DES takes a 56 bit key plus 8 parity bits (which are ignored). That gives 56 + 8 = 64 bits = 8 bytes. DES is now obsolescent, use AES instead unless you are using DES for compatibility with old code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.