0

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.

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by boboi haokip
0

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

0
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.

Edited by Nick Evan: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.