Skip to content

SHA256 hash selection algorithm for AXE

Daniel Raeder edited this page May 14, 2022 · 4 revisions

Gets the 'closest' SHA256 hash of the passed in string

Example code for Node. Will need to be adapted for browser support.

const crypto = require('crypto')

let peers = []

const p1 = crypto.createHash('sha256').update('mark/name').digest('hex') const p2 = crypto.createHash('sha256').update('mark/age').digest('hex') const p3 = crypto.createHash('sha256').update('mark/phone').digest('hex')

peers.push(p1, p2, p3) console.log(peers)

let closest = peers.reduce((min, c) => c < min? c : min) let furthest = peers.reduce((max, c) => c > max? c : max)

console.log('closest', closest, 'furthest', furthest)

This wiki is where all the GUN website documentation comes from.

You can read it here or on the website, but the website has some special features like rendering some markdown extensions to create interactive coding tutorials.

Please feel free to improve the docs itself, we need contributions!

Clone this wiki locally