- Add GETTING_STARTED.md with quick start guide and development modes - Add INSTALL.sh automated installation script - Add INSTALLATION_CHECKLIST.md, INSTALLATION_SUCCESS.md, and INSTALLATION_SUMMARY.md - Add QUICK_REFERENCE.md for common commands - Add SETUP_GUIDE.md with detailed setup instructions - Update README.md with improved project overview - Add did-wallet app dependencies and node_modules
20 lines
455 B
TypeScript
20 lines
455 B
TypeScript
import { allocUnsafe } from './alloc.js'
|
|
import { asUint8Array } from './util/as-uint8array.js'
|
|
|
|
/**
|
|
* Returns the xor distance between two arrays
|
|
*/
|
|
export function xor (a: Uint8Array, b: Uint8Array): Uint8Array {
|
|
if (a.length !== b.length) {
|
|
throw new Error('Inputs should have the same length')
|
|
}
|
|
|
|
const result = allocUnsafe(a.length)
|
|
|
|
for (let i = 0; i < a.length; i++) {
|
|
result[i] = a[i] ^ b[i]
|
|
}
|
|
|
|
return asUint8Array(result)
|
|
}
|