ASR/miniprogram/utils/auth.js

22 lines
674 B
JavaScript
Raw Permalink Normal View History

2020-08-31 16:55:41 +00:00
var sha1 = require('./sha1')
var authCodeGenerator = {
clientCode: '965cda1983f569b03abfb80dc9af8dd8',
timestamp: Date.parse(new Date()),
updateTimestamp: function () {
this.timestamp = Date.parse(new Date());
return this.timestamp;
},
randomCode: function (openid) {
this.timestamp = Date.parse(new Date());
console.log(sha1("RandomCode ["+openid+"]["+this.timestamp+"]["+this.clientCode+"]"))
return sha1("RandomCode ["+openid+"]["+this.timestamp+"]["+this.clientCode+"]");
},
signed: function (openid, token) {
return sha1("SIGN ["+openid+"]["+this.randomCode(openid)+"]["+token+"]")
}
}
module.exports = {authCodeGenerator}