[Solved] javax.crypto.BadPaddingException: Decryption error

javax.crypto.BadPaddingException: Decryption error

When using RSA encrypt body spring boot for decryption. This error occurred

I access the interface in postman. As follows:

This error appears.

Solution:

The value in raw contains all the requested parameters.

The @RequestBody is also required, otherwise it will not receive the value it should.

back-end:

    @Encrypt
    @GetMapping("/encrypt")
    public Student encrypt(){
        Student stu = new Student();
        stu.setId(1);
        stu.setName("test");
        return stu;
    }


    @Decrypt
    @PostMapping("/decrypt")
    public String testDecrypt(@RequestBody String username){
        System.out.println(username);
        return username;
    }

The correct postman is as follows:

At this time, pay attention to the data format of the transfer. There may be a problem with submitting the wrong data type. Text is not necessarily right. After that problem, I changed to JSON.

Read More: