0

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?

2
Contributors
5
Replies
6
Views
4 Years
Discussion Span
Last Post by CoilFyzx
Featured Replies
  • You could convert them to Strings (eg in hex) then there's no problem with properties files. Read More

  • 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)); Read More

0

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?

2

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));

Edited by JamesCherrill

0

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

0

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

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.