<commit_before>const crc = require('./lib/crc16-ccitt').crc16;
const CryptoJS = require('crypto-js');
const key ='<KEY>';
//const eas = require('./lib/eas');
const iv = '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0';
module.exports.getToken = function(pid){
	code = dwh(dechex(new Date().getTime()))+'64000000'+dwh(dechex(pid))+"0000"; 
	code += crc(code).toString().substr(0,4);
	console.log(code);
	code = hex2a(code);
	console.log(code);
	code = CryptoJS.AES.encrypt(code, key,{ iv: iv, padding: CryptoJS.pad.NoPadding, mode: CryptoJS.mode.CBC}).toString();
	//code = eas.DefEncryptBlock(eas.hex2str(code));
	console.log(code);
	//code = new Buffer(code).toString('base64');
	code = code.replace(/=/g,'_').replace(/\//g,']').replace(/\+/g,'[');
	console.log(code);
	return code;	
}
function dwh(h)
{
	h = "0000000"+h
	s = h.substr(-8); 
    s = s.substr(6,2)+s.substr(4,2)+s.substr(2,2)+s.substr(0,2);
	return s;
}
function dechex(number)
{
	if (number < 0) {
		number = 0xFFFFFFFF + number + 1;
	}
	return parseInt(number, 10).toString(16);
}
function hex2a(hex) {
	var str = '';
	for (var i = 0; i < hex.length; i += 2) {
		var v = parseInt(hex.substr(i, 2), 16);
		if (v) str += String.fromCharCode(v);
	}
	return str;
}<commit_msg>Fixed authToken.js<commit_after>const crc = require('./lib/crc16-ccitt').crc16;
const CryptoJS = require('crypto-js');
const key = CryptoJS.enc.Hex.parse('<KEY>')
const iv = CryptoJS.enc.Hex.parse('00000000000000000000000000000000')

module.exports.getToken = function(pid) {
    code = dwh(dechex(Date.now())) + dwh(dechex(100)) + dwh(dechex(pid)) + "0000"
    code += crc(code).toString().substr(0, 4)
    code = CryptoJS.enc.Hex.parse(code)
    code = CryptoJS.AES.encrypt(code, key, {
        iv: iv,
        padding: CryptoJS.pad.NoPadding,
        mode: CryptoJS.mode.CBC
    }).toString()
    code = code.replace(/=/g, '_').replace(/\//g, ']').replace(/\+/g, '[')
    return code
}

function dwh(h) {
    h = "0000000" + h
    s = h.substr(-8);
    s = s.substr(6, 2) + s.substr(4, 2) + s.substr(2, 2) + s.substr(0, 2)
    return s
}

function dechex(number) {
    if (number < 0) {
        number = 0xFFFFFFFF + number + 1
    }
    return parseInt(number, 10).toString(16)
}
{'fraction_non_alphanumeric': 0.21684019918515166, 'fraction_numerical': 0.06111362607514713, 'mean_word_length': 3.6331236897274635, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 5, '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': '1295388', 'n_tokens_mistral': 988, 'n_tokens_neox': 885, 'n_words': 162}