| Author |
crypt algorithm
|
Zahra Vir
Greenhorn
Joined: Dec 04, 2004
Posts: 4
|
|
any ideas on how i should do the crypt for the following: Suppose the key word is feather. Then first remove duplicate letters, yielding feathr, and append the other letters of the alphabet in reverse order. Now encrypt the letters as follows: abcdefghijklmnopqrstuvwxyz ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ feathrzyxwvusqponmlkjigdcb
|
 |
Nick George
Ranch Hand
Joined: Apr 04, 2004
Posts: 815
|
|
my first thought would be to fill an array of 26 chars, making a kind of mapping. Then, just use that mapping to encrypt what you need encrypted. Remember that you can cast chars to ints, and visa versa, such that (int)'a'=97, and (char)97='a'. That ought to get you started.
|
I've heard it takes forever to grow a woman from the ground
|
 |
Lee George
Greenhorn
Joined: Dec 15, 2004
Posts: 4
|
|
I would suggest creating a hashtable with the initial string as the key and the string you wish to convert to as the value. For example, if a converts to t, Hashtable table = new Hashtable(); table.put("a", "t"); You can then take each letter from the word and us it to extract the value you wish to convert to. For example, String currentLetter = "a"; String convertedLetter = (String)table.get(currentLetter); Hope this helps.
|
 |
 |
|
|
subject: crypt algorithm
|
|
|