import { Md5 } from 'ts-md5';

// 字符串工具类
export default class StringUtils {

    // 检查字符串是否为空
    static isNullOrEmpty(value: string | undefined): boolean {
        return value == undefined || false || value === '';
    }

    // 计算字符串 md5 值
    static getPwdMd5(value: string) {
        let ms5Result = 'WCS';
        let length = 200;
        while (ms5Result.length < length) {
            let mdsOnceValue : string = '';
            if(ms5Result == "WCS") {
                mdsOnceValue = Md5.hashStr(value);
                ms5Result = ms5Result + mdsOnceValue;
            } else {
                mdsOnceValue = Md5.hashStr(ms5Result);
                ms5Result = ms5Result + mdsOnceValue;
            }
        }
        return ms5Result.toUpperCase();
    }
}