Replies: 1 comment
-
Use readme to see how to use chacha20 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hello, i need to implement several algorithms for a university project. among them is chacha20. i was following the example with xchacha20poly1305, however, i cannot use chacha20.
this is my test code:
const nonce = randomBytes(12);
const chacha = chacha20(key, nonce);
const data = utf8ToBytes('hello, noble');
const ciphertext = chacha.encrypt(data);
const data_ = c.decrypt(ciphertext); // utils.bytesToUtf8(data_) === data
console.log('data:',bytesToUtf8(data_))
the error it returns me is as follows:
/node_modules/@noble/ciphers/_assert.js:24
throw new Error('Uint8Array expected');
^
Error: Uint8Array expected
at bytes (/Users/michelecolucci/Desktop/Bozze Tesi/ProgettiEsempio/chacha20-example/node_modules/@noble/ciphers/_assert.js:24:15)
at /Users/michelecolucci/Desktop/Bozze Tesi/ProgettiEsempio/chacha20-example/node_modules/@noble/ciphers/_arx.js:108:32
at Object. (/Users/michelecolucci/Desktop/Bozze Tesi/ProgettiEsempio/chacha20-example/example.js:7:16)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32)
at Module._load (node:internal/modules/cjs/loader:960:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)
at node:internal/main/run_main_module:23:47
Beta Was this translation helpful? Give feedback.
All reactions