amark / gun

An open source cybersecurity protocol for syncing decentralized graph data.
https://gun.eco/docs
Other
18.03k stars 1.16k forks source link

SEA - Update sea.work to support hex #1266

Closed i001962 closed 2 years ago

i001962 commented 2 years ago

This would encode to hex:

var hash1 = await SEA.work(data, null, null, {name: "SHA-256",encode:
"hex"});

but this would not verify correctly: gun.get('#').get(hash1).put(data);

This PR will first check base64 (current functionality) and if it fails now it will fall back and check hex.

i001962 commented 2 years ago

I'm curious to know what the use-case for this is?

1- It fixes what I’d call a bug. If we may use hex to create immutable data we should be able to verify it in hex rather than encoding to base64 before sea.work is called.

2 - see 1. More seriously it has to do with using a in query string as those pesky equal signs can muck things up. I like the consistency of length too but that’s not driving this. To each their own but now we have a choice for immutable data verification and referencing.

amark commented 2 years ago

EPIC