Last active
September 12, 2018 17:38
-
-
Save morloy/da43a8cbab4c3d61eb41a4578fd51461 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
import { sign } from 'tweetnacl'; | |
import { Buffer } from 'buffer'; | |
const secretKey = Buffer.from('…', 'base64'); | |
const generateCertificateForDocument = | |
(filename: string, sha256: string, user: string, email: string, userId: string, companyId: string, createdByLedgy: boolean): string => { | |
const certificate = JSON.stringify({ | |
filename, sha256, user, email, company, createdByLedgy, userId, companyId, version: '1.0.0', | |
}); | |
const signedCertificate = sign(Buffer.from(certificate), secretKey); | |
return Buffer.from(signedCertificate).toString('base64'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment