Use of a deprecated method Medium

This code uses deprecated methods, which suggests that it has not been recently reviewed or maintained. Using deprecated methods might lead to erroneous behavior.

Detector ID
java/deprecated-method@v1.0
Category
Common Weakness Enumeration (CWE) external icon

Noncompliant example

1public String encodePasswordNoncompliant(String password) {
2    // Noncompliant: uses deprecated Base64 class from Spring Framework.
3    byte[] encodedId = Base64.encode(password.toLowerCase().getBytes());
4    return new String(encodedId);
5}

Compliant example

1public String encodePasswordCompliant(String password) {
2    // Compliant: uses the standard Base64 class from the Java SDK..
3    byte[] encodedId = java.util.Base64.getEncoder().encode(password.toLowerCase().getBytes());
4    return new String(encodedId);
5}