diff --git a/package.json b/package.json index 746b957..ee9272e 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,7 @@ }, "dependencies": { "@stablelib/xchacha20poly1305": "^1.0.1", - "blake2": "^5.0.0", + "blake2b": "^2.1.4", "int64-buffer": "^1.0.0", "text-encoding": "^0.7.0", "uuid": "^8.3.2" diff --git a/src/__tests__/repertory.test.js b/src/__tests__/repertory.test.js index 82d7a7f..81efe0a 100644 --- a/src/__tests__/repertory.test.js +++ b/src/__tests__/repertory.test.js @@ -1,4 +1,4 @@ -import blake2 from 'blake2'; +import blake2b from 'blake2b'; import fs from 'fs'; import { Uint64BE } from 'int64-buffer'; @@ -6,12 +6,12 @@ import * as repertory from '../index.js'; import connection from '../networking/connection'; const TEST_HOST = process.env.TEST_HOST || 'localhost'; -const TEST_PASSWORD = process.env.TEST_PASSWORD || ''; +const TEST_PASSWORD = process.env.TEST_PASSWORD || 'cow_moose_doge_chicken'; const TEST_PORT = process.env.TEST_PORT || 20000; const calculate_sha256 = (path) => { return new Promise((resolve, reject) => { - const hash = blake2.createHash('blake2b', { digestLength: 32 }); + const hash = blake2b(32); fs.createReadStream(path) .on('data', (data) => hash.update(data)) diff --git a/src/networking/packet.js b/src/networking/packet.js index 5db3954..40dceeb 100644 --- a/src/networking/packet.js +++ b/src/networking/packet.js @@ -1,6 +1,6 @@ import { randomBytes } from 'crypto'; import { Int64BE, Uint64BE } from 'int64-buffer'; -import blake2 from 'blake2'; +import blake2b from 'blake2b'; import { TextEncoder } from 'text-encoding'; import { getCustomEncryption } from '../utils/constants'; import { @@ -156,7 +156,7 @@ export default class packet { decrypt = async () => { try { - let hash = blake2.createHash('blake2b', { digestLength: 32 }); + let hash = blake2b(32); hash = hash.update(new TextEncoder().encode(this.token)); const key = Uint8Array.from(hash.digest()); @@ -282,7 +282,7 @@ export default class packet { encrypt = async (nonce) => { try { - let hash = blake2.createHash('blake2b', { digestLength: 32 }); + let hash = blake2b(32); hash = hash.update(new TextEncoder().encode(this.token)); const key = Uint8Array.from(hash.digest());