MCPcopy
hub / github.com/mongodb/node-mongodb-native / xor

Function xor

src/cmap/auth/scram.ts:259–268  ·  view source on GitHub ↗
(a: Uint8Array, b: Uint8Array)

Source from the content-addressed store, hash-verified

257
258// XOR two buffers
259function xor(a: Uint8Array, b: Uint8Array) {
260 const length = Math.max(a.length, b.length);
261 const res = [];
262
263 for (let i = 0; i < length; i += 1) {
264 res.push(a[i] ^ b[i]);
265 }
266
267 return ByteUtils.toBase64(ByteUtils.fromNumberArray(res));
268}
269
270async function H(method: CryptoMethod, text: Uint8Array): Promise<Uint8Array> {
271 const buffer = await crypto.subtle.digest(method === 'sha256' ? 'SHA-256' : 'SHA-1', text);

Callers 1

Calls 2

maxMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected