starlight-crypto 1.0.0
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.
- package/package.json +21 -0
- package/src/starlight-crypto.mjs +29 -0
package/package.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starlight-crypto",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Starlight package for cryptographic utilities",
|
|
5
|
+
"main": "src/starlight-crypto.mjs",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "echo \"No tests yet\""
|
|
9
|
+
},
|
|
10
|
+
"keywords": [
|
|
11
|
+
"starlight",
|
|
12
|
+
"crypto",
|
|
13
|
+
"hash",
|
|
14
|
+
"hmac",
|
|
15
|
+
"uuid",
|
|
16
|
+
"base64"
|
|
17
|
+
],
|
|
18
|
+
"author": "Macedon",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {}
|
|
21
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
|
|
3
|
+
const starlightCrypto = {
|
|
4
|
+
hash: (algorithm, data) => {
|
|
5
|
+
return crypto.createHash(algorithm).update(data).digest("hex");
|
|
6
|
+
},
|
|
7
|
+
|
|
8
|
+
hmac: (algorithm, key, data) => {
|
|
9
|
+
return crypto.createHmac(algorithm, key).update(data).digest("hex");
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
base64Encode: (data) => {
|
|
13
|
+
return Buffer.from(data).toString("base64");
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
base64Decode: (data) => {
|
|
17
|
+
return Buffer.from(data, "base64").toString("utf-8");
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
randomBytes: (length = 16) => {
|
|
21
|
+
return crypto.randomBytes(length).toString("hex");
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
uuid: () => {
|
|
25
|
+
return crypto.randomUUID();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default starlightCrypto;
|