Encrypted passwords

S

Salil

I want to write a program that requires a password to allow the user to
access it. Please suggest a nice & easy to understand (and crack)
algorithm for encryption for the password !
P.S. : I said easy to crack because I want it as a assignment for a
group of First year C++ students.
(The assignment is that the students will have to crack the password)
 
J

Jarek

Salil said:
I want to write a program that requires a password to allow the user to
access it. Please suggest a nice & easy to understand (and crack)
algorithm for encryption for the password !
P.S. : I said easy to crack because I want it as a assignment for a
group of First year C++ students.
(The assignment is that the students will have to crack the password)
XOR ?

Jarek
 
B

binbag

XOR does of course beg the question of what you XOR with ?
1st years will of course be tempted to XOR with a constant key, which
means that once you've cracked one password, you've got them all.
Thus you have a layered test, OK students will crack it, smarter ones
will realise the general defect.

Although Jarek gives pretty much the simplest algorithm, if you don't
specify the algorithm than it requires >1st year skill to work out
whether it's XOR, DES, or something that's really secure.
 
V

VKV Coders

Hello , I am a newbie and I found this problem quite interesting.. Can
someone plese tell me what is this XOR algorithm, I want to try it out!
Thanks
 
I

Ian Malone

VKV said:
Hello , I am a newbie and I found this problem quite interesting.. Can
someone plese tell me what is this XOR algorithm, I want to try it out!
Thanks

^

HTH HAND
 
G

Greg

XOR does of course beg the question of what you XOR with ?
1st years will of course be tempted to XOR with a constant key, which
means that once you've cracked one password, you've got them all.
Thus you have a layered test, OK students will crack it, smarter ones
will realise the general defect.

Although Jarek gives pretty much the simplest algorithm, if you don't
specify the algorithm than it requires >1st year skill to work out
whether it's XOR, DES, or something that's really secure.

There is no more secure encyption algorithm than XOR-ing with a
one-time pad. In fact, it is the only known unbreakable encryption
algorithm.

To keep on topic, I have written below an implementation of the
algorithm in C++ that simply XORs each byte of the plaintext with the
corresponding byte of the secret key:

#include <string>
using std::string;

string
EncryptData( const string& plaintext, const string& key)
{
const int len = key.length();
assert(len >= plaintext.length());

string encryptedText;
int pos = -1;

while (++pos < len)
encryptedText += plaintext[pos] ^ key[pos];

return encryptedText;
}

For most uses, XOR is not practical since it requires that the secret
key be at least as long as the plain text (in order to guarantee that
every possible decryption of an encrypted text is just as likely as any
other). Furthermore each randomly generated key can only be used once,
meaning that both parties must each have the same long list of secret
keys in order to encrypt their messages.

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top