Add uuid to hash

This commit is contained in:
7cc5c4f330d47060 2024-09-06 16:55:01 -04:00
parent e243eb02f7
commit f7d0a17afc
Signed by: 7cc5c4f330d47060
SSH key fingerprint: SHA256:e+4tcZut1nBpe10PqjaO+Rvie0Q7W4qIvFzcUw+7riA
2 changed files with 4 additions and 4 deletions

View file

@ -38,7 +38,7 @@ module.exports = {
b.lastCmd = Date.now()
const cmd = text.split(' ')
const lang = settings.defaultLang
const verify = hashcheck(cmd)
const verify = hashcheck(cmd, uuid)
if (verify > 0) {
text = cmd.slice(0, cmd.length - 1).join(' ')
}

View file

@ -1,11 +1,11 @@
const crypto = require('crypto')
const secret = require('../secret.json')
module.exports = function (cmd) {
module.exports = function (cmd, uuid) {
const cmdWithoutHash = cmd.slice(0, cmd.length - 1).join(' ')
const _dateString = Date.now().toString()
const dateString = _dateString.slice(0, _dateString.length - 4)
const hashTrusted = `babyboom:${secret.keyTrusted}:${cmdWithoutHash}:${dateString}`
const hashOwner = `babyboom:${secret.keyOwner}:${cmdWithoutHash}:${dateString}`
const hashTrusted = `babyboom:${secret.keyTrusted}:${uuid}:${cmdWithoutHash}:${dateString}`
const hashOwner = `babyboom:${secret.keyOwner}:${uuid}:${cmdWithoutHash}:${dateString}`
const validhashT = crypto.createHash('sha256').update(hashTrusted).digest('hex')
const validhashO = crypto.createHash('sha256').update(hashOwner).digest('hex')
if (cmd[cmd.length - 1] === validhashT) {