Browse Source

Use toggleString for Key in HMAC #263

Chris van Marle 6 năm trước cách đây
mục cha
commit
be2b466376
1 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 4 3
      src/core/operations/HMAC.mjs

+ 4 - 3
src/core/operations/HMAC.mjs

@@ -28,8 +28,9 @@ class HMAC extends Operation {
         this.args = [
         this.args = [
             {
             {
                 "name": "Key",
                 "name": "Key",
-                "type": "binaryString",
-                "value": ""
+                "type": "toggleString",
+                "value": "",
+                "toggleValues": ["Hex", "Decimal", "Base64", "UTF8", "Latin1"]
             },
             },
             {
             {
                 "name": "Hashing function",
                 "name": "Hashing function",
@@ -66,7 +67,7 @@ class HMAC extends Operation {
      * @returns {string}
      * @returns {string}
      */
      */
     run(input, args) {
     run(input, args) {
-        const key = args[0],
+        const key = Utils.convertToByteString(args[0].string || "", args[0].option),
             hashFunc = args[1].toLowerCase(),
             hashFunc = args[1].toLowerCase(),
             msg = Utils.arrayBufferToStr(input, false),
             msg = Utils.arrayBufferToStr(input, false),
             hasher = CryptoApi.getHasher(hashFunc);
             hasher = CryptoApi.getHasher(hashFunc);