| | |
Fixed Period Encryption
![]() |
•
•
Join Date: Sep 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi: I need help with a program. Basically, I have a sentence, which I need to distribute into blocks of 5 letters, and then scramble the blocks in an order which I determine. Here is the exact question:
"Fixed period encryption- Given the number d and the numbers 1 to d in some order, take the blocks of d characters from the plain text and re-arrange the characters according to the order given. Ignore spaces, change all the characters to lower case and if the last grouping does not contain d characters, fill it with @ symbols. For example, if d = 5 and the order is (4,2,3,1,5), then "I like spinach salad" becomes "kliie npisa ahscl @d@a@"
With what I have right now, I managed to get a sentence, and distribute it into blocks 5. Now I need to scramble the words. Its not that I do not know what to use or do, but I'm totally lost so if you could write some code to assist me, that would help greatly, since I am a complete beginner at java. Since my knowledge is very limited as of right now, I do not know how to initiate concepts such as arrays, among other things which might make this project easier. My teacher said to use string methods such as s.indexOf, s.charAt, s.substring which may help, but I still need help with the project. Please assist me in this and thanks very much.
And now for the code:
anything with // notes are things which I put in // so that the program would run showing the distribution of the sentence into 5 letter blocks.
Thanks for all your help guys.
"Fixed period encryption- Given the number d and the numbers 1 to d in some order, take the blocks of d characters from the plain text and re-arrange the characters according to the order given. Ignore spaces, change all the characters to lower case and if the last grouping does not contain d characters, fill it with @ symbols. For example, if d = 5 and the order is (4,2,3,1,5), then "I like spinach salad" becomes "kliie npisa ahscl @d@a@"
With what I have right now, I managed to get a sentence, and distribute it into blocks 5. Now I need to scramble the words. Its not that I do not know what to use or do, but I'm totally lost so if you could write some code to assist me, that would help greatly, since I am a complete beginner at java. Since my knowledge is very limited as of right now, I do not know how to initiate concepts such as arrays, among other things which might make this project easier. My teacher said to use string methods such as s.indexOf, s.charAt, s.substring which may help, but I still need help with the project. Please assist me in this and thanks very much.
And now for the code:
Java Syntax (Toggle Plain Text)
/** * AWT Sample application * * @author * @version 1.00 09/11/04 */ public class scramble { public static void main(String[] args) { String s = "these programs encrypt"; String e = ""; String tmp = ""; int x = 1; int d = 5; // block = s.substring(d); for (int i = 0; i < s.length(); i++) { if (s.charAt(i) != ' ') { tmp += s.charAt(i); x++; } if (x>d) { tmp += ' '; x = 1; } } System.out.println(tmp); } // block1 = s.substring("d"); // for(int i = 0; i<block1.length; i++) // { // block1.indexOf("t"); //} }
Thanks for all your help guys.
![]() |
Similar Threads
- how to delete duplicate record in a table by using SQL query (MS SQL)
- Date Expire Alert (PHP)
- Looking for some advice regarding my future. Any wisdom appreciated! (IT Professionals' Lounge)
- Java Encryption and Decryption (Java)
- News Story: States Begin Requiring Encryption of Personal Data (Network Security)
- News Story: Blackmail virus returns with an 'uncrackable' 1024-bit encryption key (Network Security)
- Encryption 101 (Network Security)
- 5 - digit integer with encryption (C++)
- Advanced Encryption Standard - Help (C++)
- News Story: Exclusive: new PGP encryption upgrades for enterprise users (Network Security)
Other Threads in the Java Forum
- Previous Thread: problem with date class
- Next Thread: JavaFX question
| Thread Tools | Search this Thread |
911 actionlistener addball addressbook android api append applet application array arrays automation binary bluetooth button character chat class client code component consumer css csv database desktop eclipse ee error fractal ftp game givemetehcodez graphics gui html ide image integer j2me japplet java javaarraylist javac javaee javaprojects jni jpanel julia jvm linked linux list loan mac map method methods mobile netbeans newbie objects online oriented output panel phone printf problem program programming project projects properties recursion replaydirector reporting researchinmotion rotatetext rsa scanner se server service set sms software sort sql string swing test threads time transfer tree ubuntu update windows working





