import CryptoJS from 'crypto-js';

const CRYPTOJSKEY = 'thisis32bitlongpassphraseimusing';
const iv = '1234567890123456';
const options = {
  iv: CryptoJS.enc.Utf8.parse(iv),
  mode: CryptoJS.mode.CBC,
  padding: CryptoJS.pad.Pkcs7
};
export function encryptWithBase64(ciphertext: string) {
  const key = CryptoJS.enc.Utf8.parse(CRYPTOJSKEY);
  const encryptedData = CryptoJS.AES.encrypt(ciphertext, key, options);
  return encryptedData.toString();
}

export function decryptWithBase64(ciphertext: string) {
  const key = CryptoJS.enc.Utf8.parse(CRYPTOJSKEY);
  const decryptedData = CryptoJS.AES.decrypt(ciphertext, key, options);
  return decryptedData.toString(CryptoJS.enc.Utf8);
}
