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]
# 1
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
prometheuzza at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 2

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 > top of Java-index,Java Essentials,Java Programming...
# 3
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.
hunter9000a at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 4
> 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
prometheuzza at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 5
prometheuzz may have been pointing you towards methods like isDigit(), isLowerCase(), isUpperCase.ASCII's a bit old hat these days
roger.bagnalla at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 6
> prometheuzz may have been pointing you towards> methods like isDigit(), isLowerCase(), isUpperCase.That's a roger, Roger!
prometheuzza at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 7
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 > top of Java-index,Java Essentials,Java Programming...
# 8
> > prometheuzz may have been pointing you towards> > methods like isDigit(), isLowerCase(),> isUpperCase.> > That's a roger, Roger!What's our vector, Victor?
georgemca at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 9
> > ...> > That's a roger, Roger!> > What's our vector, Victor?Huh? What?; )
prometheuzza at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 10
> Ah, I see!> > I'll use the 'retro' solution now Why? It's not any easier.
jverda at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 11
I fear change.
Illua at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 12
> > > ...> > > That's a roger, Roger!> > > > What's our vector, Victor?> > Huh? What?> ; )Gimme the clearance, Clarence.Modern cinematic culture, prometheuzz
roger.bagnalla at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 13
> ...> 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
prometheuzza at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 14
Yes, as soon as I posted it, I realised you were in the scene ...Over
roger.bagnalla at 2007-7-12 20:45:49 > top of Java-index,Java Essentials,Java Programming...
# 15
> Yes, as soon as I posted it, I realised you were in> the scene ...> > Overroger!; )
prometheuzza at 2007-7-21 22:46:39 > top of Java-index,Java Essentials,Java Programming...
# 16

> > > > ...

> > > > That's a roger, Roger!

> > >

> > > What's our vector, Victor?

> >

> > Huh? What?

> > ; )

>

> Gimme the clearance, Clarence.

>

> Modern cinematic culture, prometheuzz

Airplane's hardly modern!

georgemca at 2007-7-21 22:46:39 > top of Java-index,Java Essentials,Java Programming...