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')

import SEA from 'gun/sea/sea.js'

let data = []

let data1 = await SEA.work('mark/name', null, null, {name: "SHA-256", encode: 'hex'})
let data2 = await SEA.work('mark/phone', null, null, {name: "SHA-256", encode: 'hex'})
let data3 = await SEA.work('mark/age', null, null, {name: "SHA-256", encode: 'hex'})

data.push(data1, data2, data3)
console.log(data)

let closest = data.reduce((min, c) => c < min? c : min)
let furthest = data.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