UNPKG

@1studio/utils

Version:

A collection of useful utilities.

31 lines (25 loc) 659 B
//@ts-nocheck import CryptoJS from 'crypto-js'; import { format } from './encrypt'; /** * Decrypt text * CryptoJS 3.x AES encryption/decryption on client side with Javascript and on server side with PHP * https://github.com/brainfoolong/cryptojs-aes-php * * @since 3.7.0 * @static * @memberof string * @param {string} text handle crypted string * @param {string} password * @return {string} * @example * * decrypt('ABCDEFG', 'password'); */ const decrypt = (text: string, password: string): string => JSON.parse( CryptoJS.AES .decrypt(text, password, { format }) .toString(CryptoJS.enc.Utf8), ); export default decrypt;