<commit_before>var express = require('express');
var bodyParser = require('body-parser');
var fs = require('fs');
var crypto = require('crypto');

// Initialize hmac crypto for checking webhook auth
var hmac = crypto.createHmac('sha1', process.env.GITSECRET || "testsecret");

// Initialize express server
var app = express();
var config = fs.readFileSync('./gitorade.config', 'utf8');
console.log(config);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false}));

// Handle default request
app.get('/', function(req, res, next){
	console.log(app.testing);
	if (app.testing === true) {
		console.log('Server on. Testing in progress\n' +
					'This should only display when testing.\n' +
					'Report issue if else!');
		res.send('Testing in progress. Hi :)');
	}
});

// Handle github webhook request
app.post('/git', function(req, res){
	console.log('/git');
	console.log(req.body);
	console.log('\n\nand now header\n\n');
	console.log(req.headers);

	//// CHECKING WEBHOOK SECRET
	// CALCULATING FROM PAYLOAD AND LOCAL SECRET
	var payload = req.body;
	hmac.update(JSON.stringify(payload));
	var sha1LocalSecret = 'sha1=' + hmac.digest('hex');
	// GETTING REMOTE SECRET
	var sha1RemoteSecret = req.headers['x-hub-signature'];

	console.log('\n\nand now header hook sig\n\n');
	console.log(sha1RemoteSecret);
	console.log(sha1LocalSecret);

	if (sha1RemoteSecret === sha1LocalSecret) {
		var usefulData = {
			
		}
		res.status(202).send('Secret ok. Hook accepted :)');
	}
	else {
		console.log("Wrong secret. Ignoring commit!");
		res.status(400).send('Wrong secret!! :(');
		return;
	}
});
<commit_msg>Trying hmac without json.stringify<commit_after>var express = require('express');
var bodyParser = require('body-parser');
var fs = require('fs');
var crypto = require('crypto');

// Initialize hmac crypto for checking webhook auth
var hmac = crypto.createHmac('sha1', process.env.GITSECRET || "testsecret");

// Initialize express server
var app = express();
var config = fs.readFileSync('./gitorade.config', 'utf8');
console.log(config);
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false}));

// Handle default request
app.get('/', function(req, res, next){
	console.log(app.testing);
	if (app.testing === true) {
		console.log('Server on. Testing in progress\n' +
					'This should only display when testing.\n' +
					'Report issue if else!');
		res.send('Testing in progress. Hi :)');
	}
});

// Handle github webhook request
app.post('/git', function(req, res){
	console.log('/git');
	console.log(req.body);
	console.log('\n\nand now header\n\n');
	console.log(req.headers);

	//// CHECKING WEBHOOK SECRET
	// CALCULATING FROM PAYLOAD AND LOCAL SECRET
	var payload = req.body;
	hmac.update(payload);
	var sha1LocalSecret = 'sha1=' + hmac.digest('hex');
	// GETTING REMOTE SECRET
	var sha1RemoteSecret = req.headers['x-hub-signature'];

	console.log('\n\nand now header hook sig\n\n');
	console.log(sha1RemoteSecret);
	console.log(sha1LocalSecret);

	if (sha1RemoteSecret === sha1LocalSecret) {
		var usefulData = {
			
		}
		res.status(202).send('Secret ok. Hook accepted :)');
	}
	else {
		console.log("Wrong secret. Ignoring commit!");
		res.status(400).send('Wrong secret!! :(');
		return;
	}
});

{'fraction_non_alphanumeric': 0.17305922061982204, 'fraction_numerical': 0.009205277692543725, 'mean_word_length': 4.415282392026578, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2568718', 'n_tokens_mistral': 1152, 'n_tokens_neox': 1087, 'n_words': 261}