Java encryption alternitive to hardcoded key

前端 未结 8 857
刺人心
刺人心 2021-02-08 13:42

I am new to encryption.

I have looked at the javax.crypto documentation and got encryption of a file to work using this code ...

File saveFile = new File         


        
8条回答
  •  Happy的楠姐
    2021-02-08 14:20

    Well if the program can decrypt the data without additional input from the user, you can't really avoid someone else from accessing the file if he has access to the program.

    If you are targeting Windows only, you might want to take a look at the Data Protection API (DPAPI). It essentially does the same thing, but the passphrase used for encryption is protected by the operating system on a user (or machine) scope. Simply put: you need the user login (or a program that runs on the given user account) to access the key (or for machine scope the login for any user on the machine).

    I don't know how to access the API from Java, but Google brings up some wrapper libraries.

提交回复
热议问题