java - Converting line of bytes to string -


i created program takes user input , converts char array. turns each char in array it's corresponding byte value, , prints of them in single line.

i creating second program want able paste line of bytes user input, , have display original message in ascii (english)

here code far:

    import java.util.scanner;       public class messagedecoder     {          public static void main(string[] args)          {               system.out.println("please enter encrypted message , press enter: ");               scanner reader = new scanner(system.in);               byte b = reader.nextbyte();          }     } 

i have tried concatenating line of bytes string, this

    system.out.println(b + ""); 

but (probably obviously) didn't work.

what need do?

just try

  system.out.println((char)b); 

however comments far can understand have "encrypted char" in numbers, hence has become 65 (2 bytes 6 , 5). problem of "decrypting" have lost information es. aa = 6565 (and char 6 char 5 ecc). need system understand how grouped.

solution set fixed (at least 3 chars since byte max 256) means becomes 065

solution b use seperatore (that not present in file es. eot (char)5.

if solution decrpyt read input (also string) loop 3 chars 3 char, cast integer --> cast char , got original char.

solution b, maybe simpler can use split function on input string

  string[] stringarray = input.split(char)5); 

then loop , on every string

    int result = integer.parseint(stringarray[i]).     char c = (char)result; 

i did not give code, hope helps


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -