qsu 1.6.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ import{randomBytes as t,createCipheriv as e,createDecipheriv as r,createHash as n}from"crypto";export function encrypt(r,n,o="aes-256-cbc",f=16,u=!1){if(!r||r.length<1)return"";const a=t(f),c=e(o,n,a);let i=c.update(r);i=Buffer.concat([i,c.final()]);const s=u?"base64":"hex";return`${a.toString(s)}:${i.toString(s)}`}export function decrypt(t,e,n="aes-256-cbc",o=!1){if(!t||t.length<1)return"";const f=o?"base64":"hex",u=t.split(":"),a=r(n,e,Buffer.from(u.shift(),f));let c=a.update(Buffer.from(u.join(":"),f));return c=Buffer.concat([c,a.final()]),c.toString()}export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,(()=>Math.floor(16*Math.random()).toString(16)))}export function md5Hash(t){return n("md5").update(t).digest("hex")}export function sha1Hash(t){return n("sha1").update(t).digest("hex")}export function sha256Hash(t){return n("sha256").update(t).digest("hex")}export function encodeBase64(t){return Buffer.from(t,"utf8").toString("base64")}export function decodeBase64(t){return Buffer.from(t,"base64").toString("utf8")}export function strToNumberHash(t){if(!t)return 0;let e=0;for(let r=0;r<t.length;r+=1)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export * from './array.js';
2
- export * from './crypto.js';
2
+ export * from './encrypt.js';
3
3
  export * from './date.js';
4
4
  export * from './format.js';
5
5
  export * from './math.js';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export*from"./array.js";export*from"./crypto.js";export*from"./date.js";export*from"./format.js";export*from"./math.js";export*from"./misc.js";export*from"./object.js";export*from"./string.js";export*from"./verify.js";
1
+ export*from"./array.js";export*from"./encrypt.js";export*from"./date.js";export*from"./format.js";export*from"./math.js";export*from"./misc.js";export*from"./object.js";export*from"./string.js";export*from"./verify.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qsu",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "QSU is a lightweight and simple module with a variety of built-in utility functions that you can utilize in your NodeJS projects.",
5
5
  "author": "Jooy2 <jooy2.contact@gmail.com>",
6
6
  "license": "MIT",
package/dist/crypto.js DELETED
@@ -1 +0,0 @@
1
- import{randomBytes as t,createCipheriv as e,createDecipheriv as r,createHash as n}from"node:crypto";export function encrypt(r,n,o="aes-256-cbc",f=16,u=!1){if(!r||r.length<1)return"";const a=t(f),c=e(o,n,a);let i=c.update(r);i=Buffer.concat([i,c.final()]);const s=u?"base64":"hex";return`${a.toString(s)}:${i.toString(s)}`}export function decrypt(t,e,n="aes-256-cbc",o=!1){if(!t||t.length<1)return"";const f=o?"base64":"hex",u=t.split(":"),a=r(n,e,Buffer.from(u.shift(),f));let c=a.update(Buffer.from(u.join(":"),f));return c=Buffer.concat([c,a.final()]),c.toString()}export function objectId(){return Math.floor(Date.now()/1e3).toString(16)+"x".repeat(16).replace(/x/g,(()=>Math.floor(16*Math.random()).toString(16)))}export function md5Hash(t){return n("md5").update(t).digest("hex")}export function sha1Hash(t){return n("sha1").update(t).digest("hex")}export function sha256Hash(t){return n("sha256").update(t).digest("hex")}export function encodeBase64(t){return Buffer.from(t,"utf8").toString("base64")}export function decodeBase64(t){return Buffer.from(t,"base64").toString("utf8")}export function strToNumberHash(t){if(!t)return 0;let e=0;for(let r=0;r<t.length;r+=1)e=(e<<5)-e+t.charCodeAt(r),e|=0;return e}
File without changes