Hi everyone,
PLease help me out with permuation cipher, an example given to me shows a plain text as abcdef...up to z and ciphered text as fghijabcdevwxyzklmnopqrstu.. Im seeing some sort of a pattern with this text,Can you guys give an example java code to cipher of decipher using permutation cipher..


6 Years
Discussion Span
Last Post by jon.kiparsky

So a permutation cipher works by scrambling the order of the plaintext while retaining the values. The problem is to work out a way to transform the order of objects in an array in a regular fashion, and then to undo that transformation.

If you're familiar with array manipulation, start by writing a method that takes an array of arbitrary length and scrambles it according to the rule
"swap the first five elements with the second five elements"

You'll have to come up with a good way to handle the likely case of an array whose length is not evenly divisible by five, this will take some thinking on your part. Think about it in terms of pairs to swap: your method will take five characters as the first of the pair, then another five as the second of the pair. If you have a complete first pair and less than five for your second, this is probably a diferent case from having an incomplete first pair. You might need some lookahead to handle this reasonably.

And no, I don't have any code examples, but you're welcome to post what you come up with, and you'll probably get some good suggestions.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.