1. Member
Join Date
Aug 2009
Posts
4
Rep Power
0

## Anyone can help??

hi everyone newbie here :D

I had cryptography program to used netbeans ide as assignment in my college. But i can't do that, because the lecturer did'nt teach yet.

Look at this command :

Write a method that receives a String as its only parameter and return the encrypted String. Call this method Encryption_mthd. (Hint: public String Encryption_mthd(String str){}).

Write another method that receives a encrypted String and return the decrypted String (the original text). Call this method Decryption_mthd. (Hint: public String Decryption_mthd(String str){})

Write a menu that asks user for input statement to be encrypted, and then show the encrypted text, and lastly per user request, decrypt it back to its original format. (Program will exit if the user insert 0).

How to 'Encrypt a String'?

1. Convert the String parameter into an array of characters.
2. Find out the equivalent integer for each character of the String parameter. (Using ASCII table).

3. Assuming the equivalent integer is stored in an integer variable called 'asciii_value'. Using the following formula calculate the encrypted integer (StudentID is equal to your last two digits of your student ID. for example if your student ID is 109087625, Student id will be 25):
int encrypted_integer = ((ascii_value + student iID) % 95) +32;

4. Then replace the equivalent char of the encrypted_integer using ASCII table with the current character.

5. Convert the array of characters into new String and return the new String.

'How to Decrypted a string'?

1. Convert the String parameter into an array of characters
2. Fing out the equivalent integer for each characters of the String parameter. (Using ASCII table).

3. Assuming the equivalent integer is stored is an integer variable called 'ascii_value'. Using the following formula calculate the decrypted integer (StudentID is equal to your last two digits of your Student ID. For example if your student ID is 109087625, Student id will be 25):

int decrypted_integer = ((ascii_value-StudentID)+95);
if (decrypted_integer > 158)
{
decrypted_integer % = 127;
} else
{
decrypted_integer - = 32;
}

4. Then replace the equivalent char of the encrypted_integer using ASCII table with the current character.

5. Convert the array of characters into new String and return the new String.

note : please help me to solve this problem or give me some clue, because i don't have any idea about that. thanks

regard_
Last edited by White; 09-03-2009 at 06:17 PM.

2. What exactly is your question and how does it relate to Netbeans? :)

3. Member
Join Date
Aug 2009
Posts
4
Rep Power
0
Originally Posted by mrmatt1111
What exactly is your question and how does it relate to Netbeans? :)
the question is how to create a code using a netbeans....anyway thanks for posted.... :D

4. Senior Member
Join Date
Dec 2008
Location
Hong Kong
Posts
473
Rep Power
10
exec netbeans.exe
in menubar, File > New Project
Categories should be Java, and Projects should be Java Application
click Next
enter Project Name, Location, main class name etc
click Finish
new Project created

then you can right click on Source Packages to create new packages, class as you like

you can now start your real programming work

if you want to test your program, right click the project , build/ clean and build, then run

5. Member
Join Date
Sep 2009
Posts
1
Rep Power
0
It's funny, I'm doing the same question)))
I guess we'r frm da same class)))))

6. Member
Join Date
Aug 2009
Posts
4
Rep Power
0
Originally Posted by mtyoung
exec netbeans.exe
in menubar, File > New Project
Categories should be Java, and Projects should be Java Application
click Next
enter Project Name, Location, main class name etc
click Finish
new Project created

then you can right click on Source Packages to create new packages, class as you like

you can now start your real programming work

if you want to test your program, right click the project , build/ clean and build, then run
thx then, but i already knew it to do that, but i dont know how to create the algorithm

Originally Posted by cyber_ingush
It's funny, I'm doing the same question)))
I guess we'r frm da same class)))))
really? who are u actually?

7. Senior Member
Join Date
Aug 2009
Posts
2,388
Rep Power
11
The question tells you all the steps to be followed. It's already an algorithm?
Have you tried to follow those steps at all?

8. Originally Posted by r035198x
Have you tried to follow those steps at all?
From the sounds of it, no. Perhaps he should talk to the teacher at this point.

9. Senior Member
Join Date
Dec 2008
Location
Hong Kong
Posts
473
Rep Power
10
for ascii, search the web

have you read point 3 of How to 'Encrypt a String'?
and that of 'How to Decrypted a string'? ...
last 2 digit of your student id is the random seed of the encryption method
suggest to use final static int to store it...

Last edited by mtyoung; 09-06-2009 at 05:27 PM.

10. Member
Join Date
Aug 2009
Posts
4
Rep Power
0
anyway thx all for revision i has been solved the problem with hint:
Encypted : public String Decryption_mthd(String str){})

Decypted : public String Encryption_mthd(String str){}).

:D

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•