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..

sanelepatrick

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.