1

I'm trying to make a password book for my computer science class. The one problem I face is how to encrypt and decrypt it. I have it so the array writes to a file, so what I'm asking is if there is a way to encrypt the array before writing to the file and then decrypt when reading the file.

So far this is my string, but I have it so you type in the website, username and password.

public String pass[][] = new String[][]{
    {"Username", "Password", "Password Hint"},
    {"admin", "d2gg6ag", "No password hint!"}
};

Thanks!

  • 3
    Related: http://stackoverflow.com/questions/27962116/simplest-way-to-encrypt-a-text-file-in-java – Thilo May 13 '16 at 02:05
  • @Thilo that somewhat helps, but I'm using a 2D array and I am just beginning coding with java. I'm still really confused about how I can use that with my array – Bryce Thompson May 13 '16 at 02:25
  • @BryceThompson: In that case, finish the other parts of the program first, for example writing your array to a file. That needs to be done anyway and allows you to hone your Java skills. You could also ask the OS to handle the encryption (such as writing the file to an encrypted USB stick). – Thilo May 13 '16 at 03:04
  • @Thilo, a password manager isn't much of a password manager if relies on the filesystem to do the encryption. You might as well just write your passwords in a text file. (But it sounds like it's a school project in an introductory class, so it doesn't really need to employ strong cryptography; it just ought to have *something* that could be replaced with a real cipher later.) – Wyzard May 13 '16 at 03:33
  • @DarkV1 Nothing personal, but I would downvote your comment if I could. This is **precisely what you should not do.** – Luke Joshua Park May 13 '16 at 04:23
  • @DarkV1 Your comment (which you removed...) implied that what you suggested was good practice. Implementing AES is just as easy with java, if not easier than what you suggested. – Luke Joshua Park May 13 '16 at 11:39
  • @LukePark. I removed the comment anyways, but alright – DarkV1 May 13 '16 at 12:06

0 Answers0