Generates HMAC-signed codes from Mongo ObjectID strings
npm install signed-objectid
Generate URL-safe signed codes based on 24-character hex string (like Mongo ObjectID)
- Requires Node 4+ (ES2015)
SIGNED_CODE_SECRETSIGNED_CODE_SECRET, a fallback secret can be provided to the module functionErrorunsign will return a null``
const signedObjectId = require('signed-objectid')('DevTestSecret')
console.log(signedObjectId.sign('507f1f77bcf86cd799439011'))
// -> $w9@jeWfZ8hayp94dM@euVr351i1KQMHxt6mLTEfFRiXRA5QZeNb4z7df8HU
console.log(signedObjectId.unsign('$w9@jeWfZ8hayp94dM@euVr351i1KQMHxt6mLTEfFRiXRA5QZeNb4z7df8HU'))
// -> 507f1f77bcf86cd799439011
``