I have a class name string. And a user input is read i.e a message or string.

Get the text message(i.e.string) from the user and convert the message into hexadecimal code and binary code. Then message is split into two parts. One is used as message end other one is used as a key, then XOR operation is performed.
can someone help me to code this? Thanks.

Recommended Answers

All 3 Replies

what do you have so far?

Member Avatar for hfx642

Don't use string as a variable name.
It will be too confusing with String, the data type.

import java.util.Scanner;
public class project {
public static void main(String[] args){



Scanner input = new Scanner(System.in);
string stringObject = new string();
System.out.println("Enter the plaintext:");
String name = input.nextLine();
stringObject.text(name);
}
}
[This is the main or sud i say the header code]



public class string {
public void text(String name){
System.out.println("The plaintext you enter is:\n" + name);
}


}

[string class]

public class hex
{
String stringToHex(String str)
{
char[] chars = str.toCharArray();
StringBuffer strBuffer = new StringBuffer();
for (int i = 0; i < chars.length; i++) {
strBuffer.append(Integer.toHexString((int) chars));
}
return strBuffer.toString();
}
}

This is my string to hex convert class. But I don't know how to include or join this class to the class project i.e. multiple class in one class. Check out the code and please help me if you can.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.