I created a SecretkeySpec object that contains a 128-bit key. I would like to have this key in String (this string should be inserted back into the original key later), so I use Base64 encoding.
This is how my key looks in raw format from an array of bytes to characters:
*P??? ?ukL|?~
So, I take the bytes and encode them like this.
byte[] okay = Base64.encode(eF.getSpec().getEncoded());
Now, when I translate it into characters, I get:
S2xEa3Ara0o5blVGYTB3WkRIeUZmZz09DQo=
Now I want to return my key back to its original format from a base64 encoded array.
String dkey = "S2xEa3Ara0o5blVGYTB3WkRIeUZmZz09DQo=";
byte[] key = null;
key = dKey.getBytes();
key = Base64.decode(key);
Now, when I check the result, I get:
DKlDkp+kJ9nUFa0wZHyFfg==
instead:
*P??? ?ukL|?~
, , .
, , , .
, -
128- , , , .
, .