1.0.2 • Published 2 years ago
simple-api-sign v1.0.2
simple-api-sign
Simple API sign is a simple implementation of API signature. It now includes JS and PHP versions with corresponding create and check methods.General projects can be used out of the box, but I do not guarantee the security of this method and the repair of future events.this module is very simple. You might as well look at the source code.Finally, I would like to thank the author of js-md5.
Others
The module also has PHP version and python version, which have the same implementation. See github.
Install
npm install simple-api-sign
Usage
const apiSign = require('simple-api-sign');
const token = 'xxx';
let data = {
source: 'products',
pk: 1003443,
ext: [
'sales',
'pv',
'uv'
]
};
// create sign of data
const signData = apiSign.create(data, token);
/** signData like this
{
source: 'products',
pk: 1003443,
ext: [
'sales',
'pv',
'uv'
],
timestamp: 1645253321,
randstr: '2jfL#J#OjLD'
_sign: 'D853EA4AD57F929E1A8A9FCD30ED8FD9'
}
*/
// check sign of signData
const isValid = apiSign.check(signData, token);
// ...your code