Encrypt and Decrypt in Java

前端 未结 7 1169
旧巷少年郎
旧巷少年郎 2020-12-01 08:24

I would like to store an encrypted password in a Java file. I saw at a solution using javax.crypto, but the problem with that was that the key was being ge

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-01 09:00

    If you use a static key, encrypt and decrypt always give the same result;

    public static final String CRYPTOR_KEY = "your static key here";
    byte[] keyByte = Base64.getDecoder().decode(CRYPTOR_KEY);
    key = new SecretKeySpec(keyByte, "AES");
    

提交回复
热议问题