Skip to content

Instantly share code, notes, and snippets.

@lvaccaro
Created August 17, 2018 22:37
Show Gist options
  • Save lvaccaro/f9e0aa000227e3fcf84c6cdeb5b39fb1 to your computer and use it in GitHub Desktop.
Save lvaccaro/f9e0aa000227e3fcf84c6cdeb5b39fb1 to your computer and use it in GitHub Desktop.
// 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