Hello good day. I have a quick question is anyone able to assist me in saving a password file. I encrypted my password and so I want to save the salt and the encrypted password(which are byte arrays). I tried using a properties file, but I soon found out that I can't. Can anyone assist me in saving these byte arrays and retrieving them please?

Recommended Answers

All 5 Replies

You could convert them to Strings (eg in hex) then there's no problem with properties files.

Thanks; but I tried that and I had some issues converting it back to a byte array when I needed it. Any help with that please?

Try javax.xml.bind.DatatypeConverter (Java SE 6 or later)
That has printBase64Binary and parseBase64Binary methods to convert byte[] to printable String and back again, eg

      byte[] b = {(byte) 99, (byte) -101};
      String s = javax.xml.bind.DatatypeConverter.printBase64Binary(b);
      System.out.println(s);
      byte[] b1  = javax.xml.bind.DatatypeConverter.parseBase64Binary(s);
      System.out.println(Arrays.toString(b1));

Wow thanks for the help. I'll give it a try and tell you if it works.

You are a Genius bro! Whew...WOW. What a Load OFF! Thanks a million I appreciate it so much. It definitely Worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.