Get Ascii value of a string letter
Hi all,
I want to make sure a password is (semi)secure. This means I have to check that the password contains at least one lower case, one uppercase and one number.
I have the ascii codes and I loop through the password, taking out each letter in it using substring.
How can I now compare each letter to the ascii ranges to check if they are valid?
Thanks,
Illu
[398 byte] By [
Illua] at [2007-11-27 8:44:53]

Have a look at the methods from the Character class: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.htmland the String class: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html
Cheers for replying,
I tried using the getBytes() method like this:
password.getBytes(password.substring(i, i+1)) >= 97 && password.getBytes(password.substring(i, i+1)) <=122
to check for lower case but I can't compare them to find out if it's between the two values.
Illu
Illua at 2007-7-12 20:45:49 >

You don't want to convert the characters to bytes, that introduces encoding and multibyte complexity that you don't need. If you want a single character from a String, use the charAt() method.
> Cheers for replying,> > I tried using the getBytes() method like this:> > ...Have a look at the methods from the Character class: http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Character.html
prometheuzz may have been pointing you towards methods like isDigit(), isLowerCase(), isUpperCase.ASCII's a bit old hat these days
> prometheuzz may have been pointing you towards> methods like isDigit(), isLowerCase(), isUpperCase.That's a roger, Roger!
Ah, I see!I'll use the 'retro' solution now but have a look at those methods too.Thanks a lot people!Illu
Illua at 2007-7-12 20:45:49 >

> > prometheuzz may have been pointing you towards> > methods like isDigit(), isLowerCase(),> isUpperCase.> > That's a roger, Roger!What's our vector, Victor?
> > ...> > That's a roger, Roger!> > What's our vector, Victor?Huh? What?; )
> Ah, I see!> > I'll use the 'retro' solution now Why? It's not any easier.
jverda at 2007-7-12 20:45:49 >

I fear change.
Illua at 2007-7-12 20:45:49 >

> > > ...> > > That's a roger, Roger!> > > > What's our vector, Victor?> > Huh? What?> ; )Gimme the clearance, Clarence.Modern cinematic culture, prometheuzz
> ...> Gimme the clearance, Clarence.> > Modern cinematic culture, prometheuzzYup, I know. But in that scene, the Huh?-s and What?-s are flying all over the place.; ) http://youtube.com/watch?v=mNRXJEE3Nz8
Yes, as soon as I posted it, I realised you were in the scene ...Over
> Yes, as soon as I posted it, I realised you were in> the scene ...> > Overroger!; )
> > > > ...
> > > > That's a roger, Roger!
> > >
> > > What's our vector, Victor?
> >
> > Huh? What?
> > ; )
>
> Gimme the clearance, Clarence.
>
> Modern cinematic culture, prometheuzz
Airplane's hardly modern!