Tag Archives: Springboot + Maven series

[Solved] RSA encryption request error: javax.crypto.badpaddingexception: decryption error

📖 Abstract


Share today — RSA encryption request error: javax. Crypto. Badpaddingexception: decryption error , welcome to pay attention!

Read related articles: spring boot + security based on the separation of the front and back RSA password encryption login process


🌂 resolvent

In the login method, the space can be replaced by a + sign, just ask if you want to be coquettish

String inputDecryptData = "";
        try {
            Object privateKey = redisUtil.get(Constant.RSA_PRIVATE_KEY);

            inputDecryptData =  RSAUtils.decrypt(password.replaceAll(" ","+"), RSAUtils.getPrivateKey(privateKey.toString()));
        } catch (Exception e) {
            log.error("RSA encryption and decryption exceptions occurred ======>", e);
            throw new BizException("RSA encryption and decryption exception occurred");
        }

Finally, thank you for watching patiently, leaving a like collection is your greatest encouragement to me!