I am trying to encrypt and decrypt the password and for these generation keys it is still so good. Now I need to save this key in the properties file, but when I add the key, it looks like this:
So, I suspect that something might be wrong from my code?!?!
And there is part of my code =
private byte[] key = new byte[16]; public void addProperties(String x, String z) { Properties properties = new Properties(); String propertiesFileName = "config.properties"; try { OutputStream out = new FileOutputStream(propertiesFileName); properties.setProperty(x, z); properties.store(out, null); } catch (IOException e) { e.printStackTrace(); } } public void generateKey() { KeyGenerator keygen; SecretKey secretKey; byte[] keybyte = new byte[64]; try { keygen = KeyGenerator.getInstance("AES"); keygen.init(128); secretKey = keygen.generateKey(); keybyte = secretKey.getEncoded(); key = keybyte;
Thanks for the help. All answers are acceptable.
source share