package com.eactive.ext.kjb.spring;

import com.eactive.ext.kjb.safedb.KjbSafedbWrapper;
import org.springframework.security.crypto.password.PasswordEncoder;

public class KjbSafedbPasswordEncoder implements PasswordEncoder {
    @Override
    public String encode(CharSequence rawPassword) {
        KjbSafedbWrapper safedb = KjbSafedbWrapper.getInstance();
        return safedb.encryptPassword(rawPassword.toString());
    }

    @Override
    public boolean matches(CharSequence rawPassword, String encodedPassword) {
        KjbSafedbWrapper safedb = KjbSafedbWrapper.getInstance();
        String encoded = safedb.encryptPassword(rawPassword.toString());
        return encoded.equals(encodedPassword);
    }
}
