Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Tiny Encrytion Algorithm (TEA)

807591Oct 31 2007 — edited May 20 2008
Hi Guys!

I am currently developing the Tiny Encrytion Algorithm

Currenlty is takes in a number to encrytp and works fine but I want to ammend this so it takes in a string.

My current "get" method is as follows:
public void getNumber() {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int count = 0, idx = 0;
     
        try {
            String number = br.readLine();
            while (count <= 1) {
                num_array[count++] = Integer.parseInt(number.substring(idx, idx + 2));
                idx += 2;
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        } catch (NumberFormatException ex) {
            ex.printStackTrace();
            System.out.println("You have entered an invalid number");
        }
    }
How do I go about amending this to take in a String, but still cut it up and save it to an Integer array? (The integer array is required for the encrytion process at a later stage).

So in other words, i need to get from String to Integer, while cutting it up!!

I have played about with the charAt() and toBytes() method but i'm just going round in circles! :(

Cheers!!!

Edited by: smitty350z on Oct 31, 2007 4:49 AM
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2008
Added on Oct 31 2007
17 comments
477 views