Created
August 17, 2018 22:37
-
-
Save lvaccaro/f9e0aa000227e3fcf84c6cdeb5b39fb1 to your computer and use it in GitHub Desktop.
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
// include library from https://opentimestamps.org/assets/javascripts/vendor/opentimestamps.min.js | |
const file = 'Hello World!' | |
const op = new OpenTimestamps.Ops.OpSHA256() | |
const enc = new TextEncoder() | |
const buffer = enc.encode(file) | |
const detachedTimestamp = OpenTimestamps.DetachedTimestampFile.fromBytes(op, buffer) | |
OpenTimestamps.stamp(detachedTimestamp).then( ()=>{ | |
const serializedTimestamp = detachedTimestamp.serializeToBytes() | |
const detachedOts = OpenTimestamps.DetachedTimestampFile.deserialize(serializedTimestamp) | |
// note that `detachedTimestamp` is equals to `detachedOts` | |
console.log(detachedTimestamp) | |
console.log(detachedOts) | |
const infoResult = OpenTimestamps.info(detachedTimestamp) | |
console.log(infoResult) | |
const infoResult_ = OpenTimestamps.info(detachedOts) | |
console.log(infoResult_) | |
}).catch(err => { | |
console.error(err); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment