Browse Source

default buffer lengths to relevant sodium keys

Kieran Gibb 2 years ago
parent
commit
4be13f8c17
No known key found for this signature in database
1 changed files with 1 additions and 0 deletions
  1. 1
    0
      index.js

+ 1
- 0
index.js View File

@@ -74,6 +74,7 @@ class Crypto {
74 74
   }
75 75
 
76 76
   toBuffer (stringOrBuffer, lengths) {
77
+    if (!lengths) lengths = [sodium.crypto_sign_PUBLICKEYBYTES, sodium.crypto_secretbox_KEYBYTES]
77 78
     if (typeof lengths === 'number') lengths = [lengths]
78 79
     if ((Buffer.isBuffer(stringOrBuffer)) && (lengths.indexOf(stringOrBuffer.length) > -1)) return stringOrBuffer
79 80
     assert(typeof stringOrBuffer === 'string', 'Key is incorrect type')