buffer test

This commit is contained in:
2024-06-18 21:09:19 +01:00
parent ff7f7470fc
commit a7ccc5a233

View File

@@ -73,6 +73,12 @@ app.post('/api', (req, res) => {
const hmac = crypto.createHmac('sha256', GITEA_SECRET); const hmac = crypto.createHmac('sha256', GITEA_SECRET);
const digest = `sha256=${hmac.update(payload).digest('hex')}`; const digest = `sha256=${hmac.update(payload).digest('hex')}`;
// Buffer lengths
const bufferSignature = Buffer.from(signature);
const bufferDigest = Buffer.from(digest);
console.log(bufferDigest, bufferSignature)
if (crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(digest))) { if (crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(digest))) {
// Secret is valid, update the repository // Secret is valid, update the repository
exec('/home/gnome.sh', (err, stdout, stderr) => { exec('/home/gnome.sh', (err, stdout, stderr) => {