# Anyone can help??

• 08-28-2009, 09:50 PM
White
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_
• 08-29-2009, 02:31 AM
mrmatt1111
What exactly is your question and how does it relate to Netbeans? :)
• 09-03-2009, 06:19 PM
White
Quote:

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
• 09-03-2009, 07:14 PM
Fubarable
Have a look here: The Java™ Tutorials
• 09-04-2009, 07:01 AM
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
• 09-04-2009, 04:16 PM
cyber_ingush
It's funny, I'm doing the same question)))
I guess we'r frm da same class)))))
• 09-04-2009, 08:55 PM
White
Quote:

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

Quote:

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?
• 09-04-2009, 09:20 PM
r035198x
The question tells you all the steps to be followed. It's already an algorithm?
Have you tried to follow those steps at all?
• 09-04-2009, 09:51 PM
Fubarable
Quote:

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.
• 09-05-2009, 04:44 AM
mtyoung
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...