Encrypted passwords

Discussion in 'C++' started by Salil, Sep 13, 2005.

  1. Salil

    Salil Guest

    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)
     
    Salil, Sep 13, 2005
    #1
    1. Advertising

  2. Salil

    Jarek Guest

    Salil wrote:
    > 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
     
    Jarek, Sep 13, 2005
    #2
    1. Advertising

  3. Salil

    Guest

    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.
     
    , Sep 13, 2005
    #3
  4. Salil

    VKV Coders Guest

    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
     
    VKV Coders, Sep 13, 2005
    #4
  5. Salil

    Ian Malone Guest

    VKV Coders wrote:
    > 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

    --
    imalone
     
    Ian Malone, Sep 13, 2005
    #5
  6. Salil

    Greg Guest

    wrote:
    > 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
     
    Greg, Sep 13, 2005
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Leszek
    Replies:
    1
    Views:
    350
  2. Framework fan
    Replies:
    3
    Views:
    384
    Framework fan
    Apr 12, 2004
  3. Dan
    Replies:
    2
    Views:
    331
    Kevin Spencer
    May 4, 2004
  4. Alek Davis

    Using encrypted dB connection string

    Alek Davis, May 21, 2004, in forum: ASP .Net
    Replies:
    12
    Views:
    2,921
    Alek Davis
    Jun 3, 2004
  5. Michael

    Encrypted mail in ASP.NET

    Michael, Aug 13, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    930
    Michael
    Aug 16, 2004
Loading...

Share This Page