How to encrypt/decrypt a file in Java?

前端 未结 6 1547
滥情空心
滥情空心 2021-01-16 09:07

I am writing a Java application which can \"encrypt\" and consequently \"decrypt\" whatever binary file.

I am just a beginner in the \"cryptography\" area so I would

6条回答
  •  情深已故
    2021-01-16 09:53

    Use the password to encrypt your data. You could for example repeat the password so that it matches the byte array's length and then do something like

    data[i] = data[i] >> password[i];
    

    Edit: if you wanted to store the password, you would have to encrypt it. Which - at least when using symmetrical cryptosystems - will be inherently insecure.

提交回复
热议问题