0

im creating a program that will convert certain character into its ascii value then i will change the value. for example the ascii value of A is 65 right? but i want to change the value of it into 1 so if i input A the output of it is 1. how am i supposed to do this? pls give some ideas. tnx

2
Contributors
3
Replies
4
Views
5 Years
Discussion Span
Last Post by JamesCherrill
0

A Java char is, by definition, a numeric value that represents a character. So you can freely mix character representations such as 'a' or 'Z' and numeric expressions, eg

int i = 'C';        // i = 67
int j = 'C' - 'A';  // j = 2
0

if i do that then i must have many declarations to be used. im trying to do a very simple password encryption.

0

Basically you can convert the password string to an array of chars, and do your arithmetic on that in a simple loop - here's some pseudo-code to point you in the direction:
String pw = ... get the password
char[] ca = pw.toCharArray() // now you have the chars separated into the array
loop thru array adding/subtracting some value from each char
pw = new String(ca) // convert char arry back to a String

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.