package com.ics.system.util;

import com.ics.common.utils.security.Md5Utils;
import com.ics.system.domain.User;

/**
 * 密码加/解密
 */
public class PasswordUtils {

    public static boolean matches(User user, String newPassword) {
        return user.getPassword().equals(encryptPassword(user.getUsername(), newPassword, user.getSalt()));
    }

    public static String encryptPassword(String username, String password, String salt) {
        return Md5Utils.hash(username + password + salt);
    }
}
