import { Injectable } from '@angular/core';
import { Md5 } from 'ts-md5';
import CryptoJS from 'crypto-es';

@Injectable({
  providedIn: 'root',
})
export class CryptoService {
  constructor() {}
  md5(str: string): string {
    const pwd = Md5.hashStr(str).toLowerCase();
    return pwd;
  }
  aesEncrypt(str: string, key: string): string {
    return CryptoJS.AES.encrypt(str, key).toString();
  }
  aesDecrypt(str: string, key: string): string {
    return CryptoJS.AES.decrypt(str, key).toString(CryptoJS.enc.Utf8);
  }
}
