UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

2 lines 686 B
import e from"../errors/lucid-error.mjs";import{translate as t}from"../../libs/i18n/translate.mjs";import n from"node:crypto";const r=e=>n.createHash(`sha512`).update(e).digest(`hex`).substring(0,32),i=(e,t)=>{let i=r(t),a=n.randomBytes(16).toString(`hex`).slice(0,16),o=n.createCipheriv(`aes-256-cbc`,i,a),s=o.update(e,`utf8`,`hex`);return s+=o.final(`hex`),`${a}:${s}`},a=(i,a)=>{let[o,s]=i.split(`:`);if(!o||!s)throw new e({message:t(`server:core.security.secrets.encrypted.invalid`)});let c=r(a),l=n.createDecipheriv(`aes-256-cbc`,c,o),u=l.update(s,`hex`,`utf8`);return u+=l.final(`utf8`),u.toString()};export{a as decrypt,i as encrypt}; //# sourceMappingURL=encrypt-decrypt.mjs.map