Below code is always returning false in my custom plugin. Is there any working A

Below code is always returning false in my custom plugin. Is there any working API available to check if the username, password supplied is valid? or am I missing something? Please help.

MessageDigest mdg = MessageDigest.getInstance("SHA-512");
                    byte[] passwordBytes = password.getBytes("UTF-8");
                    byte[] hashBytes = mdg.digest(passwordBytes);
                    byte[] hashedPasswordBytes = Base64.encodeBase64(hashBytes);
                    UserService userService = ServiceLocator.getUserService(sc);
                    boolean valid = true;
                    try {
                              valid = userService.isPasswordValid(user, password);
                              System.out.println("1.valid="+valid);
                              valid = userService.isUserPasswordValid(user, hashedPasswordBytes);
                              System.out.println("2.valid="+valid);

OriginalPostID-181169

OriginalPostID-181169

  Discussion posts and replies are publicly visible