Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > User definable letter swapping

Reply
Thread Tools

User definable letter swapping

 
 
Protoman
Guest
Posts: n/a
 
      01-05-2007
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!!!!

 
Reply With Quote
 
 
 
 
Bjoern Doebel
Guest
Posts: n/a
 
      01-05-2007
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
 
Reply With Quote
 
 
 
 
Jacek Dziedzic
Guest
Posts: n/a
 
      01-05-2007
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fully definable ports of array of std_logic_vectors? paragon.john@gmail.com VHDL 5 12-20-2007 07:09 PM
TD maximum height definable? Bliv HTML 0 08-16-2006 03:53 PM
Re: big letter -> small letter Andrew McNamara Python 2 07-06-2004 02:09 PM
big letter -> small letter vertigo Python 4 07-06-2004 07:23 AM
RE: big letter -> small letter Tony Meyer Python 0 07-06-2004 07:11 AM



Advertisments