Hi.
I have a class to generate a random password.
Let's say the output of that class is :
y0v{fwu-ss}5
//this is what Utils.unscramble returns
char[] password = new char[] {
121,
48,
118,
123,
102,
127,
102,
119,
117,
45,
115,
115,
125,
53,
};
if i use the variable "password" as this:
.......
ks.setKeyEntry(alias, key1, password, chain);
ks.store(os, password);
....
i get an exception:
Key protection algorithm not found: java.security.UnrecoverableKeyException: Encrypt Private Key failed: getSecretKey failed: Password is not ASCII - reported by ks.setKey (...) code
and
Failed to encrypt safe contents entry: java.io.IOException: getSecretKey failed: Password is not ASCII - reported by ks.store(...).
At this point i had no clue why the exceptions were happening.
Changing the code above by
.......
ks.setKeyEntry(alias, key1, "y0v{fwu-ss}5".toCharArray(), chain);
ks.store(os, "y0v{fwu-ss}5".toCharArray());
....
For my disbelief the code works like suposed to, no errors or exceptions at all.
Now, what i'm missing here?
I even tryed to do this with no luck:
char[] result = Utils.unscramble();
String r = new String(result);
String password = r.trim();
....
ks.store(...., password.toCharArray(),...);
Why is still complaining about password not being ascii ?
Thank you.
Message was edited by:
noe.rocha