Created
September 7, 2021 23:33
-
-
Save rococtz/77bedb792e4ce4ae960999e6d779432f to your computer and use it in GitHub Desktop.
GUN_ENCRYPTION
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////////////////////////// | |
// On my side - logged in as myself | |
/////////////////////////////////// | |
var myPair = gun.user()._.sea; | |
// retrieve bob's user | |
var bob = gun.user(bobPublicKey); | |
// generate encryption secret using bob's epub and my pair | |
// this means only bob will be able to generate this secret | |
var secret = await SEA.secret(bob.epub, myPair) | |
// encrypt the data using the secret | |
var encryptedData = await SEA.encrypt('private message for bob', await SEA.secret(bob.epub, myPair)); | |
//////////////////////////////////// | |
// on Bob's side - logged in as Bob | |
/////////////////////////////////// | |
var myPair = gun.user()._.sea; | |
// generate the secret - this will output the same secret generated by myself | |
// but this time we generate with bobs pair and my epub | |
var secret = await SEA.secret(myPair.epub, bob) | |
// just decrypt the data using the secret | |
var decryptedData = await SEA.decrypt(encryptedData, secret); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment