-3

Okay so I'm trying to do some steganography, and I'm trying to convert each character from the inputted message to an integer, which I then use to set values of my pixel.

To convert from string to an integer I'm using this line of code:-

int value = Character.getNumericValue(message.charAt(j)); 

However When I would convert, all my integers for my letters were 87 less than they needed to be. So I fixed that by adding 87

Then I had an issue where my numbers were being converted to an integer 48 less than they needed to be, so I fixed that by adding 48.

However now that I'm trying to convert symbols, 'int value' is being set as -1 for every symbol. (Also not too much of a problem, but my capital letters end up become lower case ones)

So my question is how do I get around that? Or is there another method of conversion I need to use?

Edit:- So what I want is that, if I have a symbol in my message, I want it to be encoded in an Image correctly, So when I decode it the message will be decoded correctly, showing those symbols.

pkbulletz
  • 7
  • 3
  • This isn't clear. Please provide an example of the input/output that you require. – Oliver Charlesworth Feb 22 '15 at 11:18
  • 1
    If everyone focuses on how to correctly turn a character to its ascii value, this has an answer [here](http://stackoverflow.com/questions/16458564/convert-string-to-ascii-value-in-java). Maybe pointing out why `int value = Character.getNumericValue(message.charAt(j));` doesn't do the expected would be nice. Even though it's right there in the documentation... – Reti43 Feb 22 '15 at 11:42

1 Answers1

0

You are not doing the wrong conversion; the wrong thing that you are doing is conversion itself because a character already is an integer.

Just use that character as if you would use an int value. As an example, you could have written

int value = message.charAt(j);
Marko Topolnik
  • 195,646
  • 29
  • 319
  • 436
  • I'm just getting '/' when I try convert symbols, also is it possible for me to still get spaces when I decode my message (i.e. 'testing 123' gets decoded into 'testing 123' instead of 'testing123') – pkbulletz Feb 22 '15 at 11:34
  • Gets decoded by what code? The numeric value of space is 32, there is nothing special about it. – Marko Topolnik Feb 22 '15 at 11:45