| | |
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 |
android api applet application apps array arrays automation awt bidirectional binary birt bluetooth businessintelligence busy_handler(null) card chat class classes client code collision columns component constructor crashcourse database designadrawingapplicationusingjavajslider draw eclipse error errors eventlistener exception expand fractal game givemetehcodez graphics gui guidancer html ide image inetaddress integer intellij j2me java javadoc javafx javamicroeditionuseofmotionsensor javaprojects jme jni jpanel jtree julia linux list loop machine map method methods mobile mobiledevelopmentcreatejar myaggfun netbeans newbie oracle plazmic print problem program programming project radio recursion scanner server set sharepoint smart sms smsspam sort sortedmaps sql string subclass support swing textfield threads tree unlimited utility webservices windows





