Update comments

This commit is contained in:
Andy Wang 2020-01-14 01:21:37 +00:00
parent 8239db93f4
commit a6d85aff1b
2 changed files with 6 additions and 12 deletions

View file

@ -37,8 +37,8 @@
/** /**
* Construct Chacha20 instance with key and nonce * Construct Chacha20 instance with key and nonce
* Key should be Uint8Array with 32 bytes * Key should be a 32 byte array
* None should be Uint8Array with 8 bytes * None should be an 8 or 12 byte array
* *
* *
* @throws {Error} * @throws {Error}

View file

@ -46,8 +46,8 @@
/** /**
* Construct SalSa20 instance with key and nonce * Construct SalSa20 instance with key and nonce
* Key should be Uint8Array with 32 bytes * Key should be a 16 or 32 byte array
* None should be Uint8Array with 8 bytes * None should be an 8 byte array
* *
* *
* @throws {Error} * @throws {Error}
@ -122,12 +122,6 @@ const Salsa20 = function (key, nonce) {
* @private * @private
*/ */
Salsa20.prototype._update = function (data) { Salsa20.prototype._update = function (data) {
/*
if (data.length === 0) {
throw new Error("Data should be type of bytes (Uint8Array) and not empty!");
}
*/
const output = new Uint8Array(data.length); const output = new Uint8Array(data.length);
// core function, build block and xor with input data // // core function, build block and xor with input data //
@ -146,7 +140,7 @@ Salsa20.prototype._update = function (data) {
/** /**
* Encrypt data with key and nonce * Encrypt data with key and nonce
* *
* @param {Uint8Array} data * @param {[number]} data
* @return {Uint8Array} * @return {Uint8Array}
*/ */
Salsa20.prototype.encrypt = function (data) { Salsa20.prototype.encrypt = function (data) {
@ -156,7 +150,7 @@ Salsa20.prototype.encrypt = function (data) {
/** /**
* Decrypt data with key and nonce * Decrypt data with key and nonce
* *
* @param {Uint8Array} data * @param {[number]} data
* @return {Uint8Array} * @return {Uint8Array}
*/ */
Salsa20.prototype.decrypt = function (data) { Salsa20.prototype.decrypt = function (data) {