Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   User definable letter swapping (http://www.velocityreviews.com/forums/t459650-user-definable-letter-swapping.html)

Protoman 01-05-2007 05:44 AM

User definable letter swapping
 
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!!!!


Bjoern Doebel 01-05-2007 07:23 AM

Re: User definable letter swapping
 
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

Jacek Dziedzic 01-05-2007 06:09 PM

Re: User definable letter swapping
 
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.


All times are GMT. The time now is 06:31 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.