| Author |
Read encrypted string from properties file
|
arnold yan
Ranch Hand
Joined: May 31, 2002
Posts: 40
|
|
I'm writing a password verification utility. I want to create a properties file with all users and their passwords in name/value pairs, such as user1=password1, where password is encrypted with 3DES. I added following entry in the properties file named "users.properties" tom=A������A�U�� but when I tried to retireve the encrypted password using following code, Properties users = new Properties(); users.load(new FileInputStream("c://users.properties")); String password = users.getProperty("tom"); The string returned is A�??��?A�U��, which is different than what is in the file and can not be decrypted. The weird thing is, if I use the following code to pull the password, BufferedReader bf = new BufferedReader(new InputStreamReader(new FileInputStream("c://users.properties"))); String line = bf.readLine(); password = line.substring(line.indexOf("=") + 1); I got the same password as what is in the file - A������A�U��. Can someone tell me what is going on? Thanks!
|
 |
D Rog
Ranch Hand
Joined: Feb 07, 2004
Posts: 471
|
|
Yes, I can. [q] The load and store methods load and store properties in a simple line-oriented format specified below. This format uses the ISO 8859-1 character encoding. Characters that cannot be directly represented in this encoding can be written using Unicode escapes ; only a single 'u' character is allowed in an escape sequence. The native2ascii tool can be used to convert property files to and from other character encodings. The loadFromXML(InputStream) and storeToXML(OutputStream, String, String) methods load and store properties in a simple XML format. By default the UTF-8 character encoding is used, however a specific encoding may be specified if required. An XML properties document has the following DOCTYPE declaration: <!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd"> [/q]
|
Get power of your iPod with MediaChest | Minimal J2EE container is here | Light weight full J2EE stack | My blog | Co-author of "Windows programming in Turbo Pascal"
|
 |
arnold yan
Ranch Hand
Joined: May 31, 2002
Posts: 40
|
|
I'm using jdk 1.4, so loadFromXML is not available. Is there any other way that I can still use properties and get around this encoding mess? Thanks.
|
 |
 |
|
|
subject: Read encrypted string from properties file
|
|
|