@truto/truto-jsonata 1.0.48 → 1.0.49
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/README.md +39 -1
- package/dist/browser/index.js +6050 -2693
- package/dist/browser/index.js.map +55 -18
- package/dist/cjs/index.cjs +6050 -2693
- package/dist/cjs/index.cjs.map +55 -18
- package/dist/esm/index.js +17 -1
- package/dist/esm/index.js.map +4 -4
- package/dist/functions/digest.d.ts +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -999,7 +999,13 @@ Blob (13 bytes) {
|
|
|
999
999
|
<details>
|
|
1000
1000
|
<summary>digest(text, algorithm = 'SHA-256', stringType = 'hex')</summary>
|
|
1001
1001
|
|
|
1002
|
-
Generates a cryptographic hash of the input text using a specified hashing algorithm and output format.
|
|
1002
|
+
Generates a cryptographic hash of the input text using a specified hashing algorithm and output format.
|
|
1003
|
+
|
|
1004
|
+
**Supported Algorithms:**
|
|
1005
|
+
- SHA algorithms (SHA-1, SHA-256, SHA-384, SHA-512) use the [Web Crypto API's `crypto.subtle.digest()`](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest). See [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest#supported_algorithms) for the complete list of supported algorithms.
|
|
1006
|
+
- MD5 uses the `md5.js` library (since MD5 is not supported by Web Crypto API).
|
|
1007
|
+
|
|
1008
|
+
**Output Formats:** 'hex', 'base64', and 'base64-urlSafe'.
|
|
1003
1009
|
|
|
1004
1010
|
**Example:**
|
|
1005
1011
|
|
|
@@ -1037,7 +1043,39 @@ const expression3 = trutoJsonata("$digest(text, algorithm, stringType)");
|
|
|
1037
1043
|
expression3.evaluate({ text: text3, algorithm: algorithm3, stringType: stringType3 }).then(result => {
|
|
1038
1044
|
console.log(result);
|
|
1039
1045
|
// Output: "Xh3mV+fAAG7ScGPjo4PElmR3obnFzGrxnbwGpEE4lI4="
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
// Example 4: MD5 Algorithm, Hex Output
|
|
1049
|
+
const text4 = '42';
|
|
1050
|
+
const algorithm4 = 'MD5';
|
|
1051
|
+
const stringType4 = 'hex';
|
|
1052
|
+
|
|
1053
|
+
const expression4 = trutoJsonata("$digest(text, algorithm, stringType)");
|
|
1054
|
+
expression4.evaluate({ text: text4, algorithm: algorithm4, stringType: stringType4 }).then(result => {
|
|
1055
|
+
console.log(result);
|
|
1056
|
+
// Output: "a1d0c6e83f027327d8461063f4ac58a6"
|
|
1057
|
+
});
|
|
1040
1058
|
|
|
1059
|
+
// Example 5: MD5 Algorithm, Base64 Output
|
|
1060
|
+
const text5 = '42';
|
|
1061
|
+
const algorithm5 = 'MD5';
|
|
1062
|
+
const stringType5 = 'base64';
|
|
1063
|
+
|
|
1064
|
+
const expression5 = trutoJsonata("$digest(text, algorithm, stringType)");
|
|
1065
|
+
expression5.evaluate({ text: text5, algorithm: algorithm5, stringType: stringType5 }).then(result => {
|
|
1066
|
+
console.log(result);
|
|
1067
|
+
// Output: "odDG6D8CcyfYRgYj9KxYpg=="
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
// Example 6: MD5 Algorithm, Base64 URL-Safe Output
|
|
1071
|
+
const text6 = '42';
|
|
1072
|
+
const algorithm6 = 'MD5';
|
|
1073
|
+
const stringType6 = 'base64-urlSafe';
|
|
1074
|
+
|
|
1075
|
+
const expression6 = trutoJsonata("$digest(text, algorithm, stringType)");
|
|
1076
|
+
expression6.evaluate({ text: text6, algorithm: algorithm6, stringType: stringType6 }).then(result => {
|
|
1077
|
+
console.log(result);
|
|
1078
|
+
// Output: "odDG6D8CcyfYRgYj9KxYpg"
|
|
1041
1079
|
});
|
|
1042
1080
|
|
|
1043
1081
|
```
|