User definable letter swapping

Discussion in 'C++' started by Protoman, Jan 5, 2007.

  1. Protoman

    Protoman Guest

    How would I write a user defnable letter swapping algorithm? I've
    written an Enigma encrypting program, and I need to redo the plugboard
    function. Right now, the letter swapping is fixed. I need to allow the
    user to swap 23 pairs of characters. As you may have guessed, I'm using
    an alphabet of 36 characters, A-Z and 0-9. Thanks!!!!
     
    Protoman, Jan 5, 2007
    #1
    1. Advertising

  2. Protoman wrote:
    > How would I write a user defnable letter swapping algorithm? I've
    > written an Enigma encrypting program, and I need to redo the plugboard
    > function. Right now, the letter swapping is fixed. I need to allow the
    > user to swap 23 pairs of characters. As you may have guessed, I'm using
    > an alphabet of 36 characters, A-Z and 0-9. Thanks!!!!


    Why not put the 18 pairs (36/2!) into a file and read them at program startup?

    Bjoern
     
    Bjoern Doebel, Jan 5, 2007
    #2
    1. Advertising

  3. Protoman wrote:
    > How would I write a user defnable letter swapping algorithm? I've
    > written an Enigma encrypting program, and I need to redo the plugboard
    > function. Right now, the letter swapping is fixed. I need to allow the
    > user to swap 23 pairs of characters. As you may have guessed, I'm using
    > an alphabet of 36 characters, A-Z and 0-9. Thanks!!!!


    The easy way:

    Have two const strings -- one with the cleartext alphabet,
    the other with the ciphertext alphabet. Then, whenever the
    user enters a character, find it in the cleartext alphabet,
    remember the position 'i' at which you found it, return to
    the user the i-th character of the cipherthext alphabet.

    The more-difficult way:

    Use a std::map, indexed by the cleartext characters
    in which you store ciphertext characters.

    If you want these alphabets to be changed without
    having to recompile the program, follow Bjoern's suggestion.

    HTH,
    - J.

    HTH,
    - J.
     
    Jacek Dziedzic, Jan 5, 2007
    #3
    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. vertigo

    big letter -> small letter

    vertigo, Jul 6, 2004, in forum: Python
    Replies:
    4
    Views:
    774
    Reinhold Birkenfeld
    Jul 6, 2004
  2. Tony Meyer

    RE: big letter -> small letter

    Tony Meyer, Jul 6, 2004, in forum: Python
    Replies:
    0
    Views:
    511
    Tony Meyer
    Jul 6, 2004
  3. Andrew McNamara

    Re: big letter -> small letter

    Andrew McNamara, Jul 6, 2004, in forum: Python
    Replies:
    2
    Views:
    760
    Scott David Daniels
    Jul 6, 2004
  4. Bliv
    Replies:
    0
    Views:
    738
  5. Replies:
    5
    Views:
    862
Loading...

Share This Page