Skip to content

Instantly share code, notes, and snippets.

@maca134
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maca134/a6b9c51925e97e544adb to your computer and use it in GitHub Desktop.
Save maca134/a6b9c51925e97e544adb to your computer and use it in GitHub Desktop.
/*
23:29:53 "EPOCH_clientInit: Hash: s3cave12i.008da5b19 | Verify Result: true"
23:29:53 "EPOCH_onEachFrame: Hash: urw32vfzt.b500bd86c | Verify Result: true"
23:29:55 "EPOCH_masterLoop: Hash: q3rowbiqo.34f6d340e | Verify Result: true"
23:29:55 "EPOCH_client_rejectPlayer: Hash: qzt12tqbm.83339f58d | Verify Result: true"
23:29:55 "EPOCH_clientRespawn: Hash: 3rndiefvx.78c7a9ffe | Verify Result: true"
23:29:56 "EPOCH_KeyDown: Hash: rhmlztikm.8cac0bfc5 | Verify Result: true"
*/
MMC_fnc_hashString = {
private ['_str', '_seed', '_dic', '_strArr', '_seedArr', '_seedLength', '_dicLength', '_hash'];
_str = [_this, 0, '', ['']] call BIS_fnc_param;
_seed = [_this, 1, '01234567', ['']] call BIS_fnc_param;
_dic = [_this, 2, '0123456789abcdef', ['']] call BIS_fnc_param;
if ((_seed find '.') > -1) exitWith {throw 'Seed can not contain a dot/period';};
_strArr = toArray _str;
_seedArr = toArray _seed;
_seedLength = count _seedArr;
for "_i" from 0 to (count _strArr) -1 do {
private ['_j', '_c', '_s', '_r'];
_j = _i % _seedLength;
_c = _strArr select _i;
_s = _seedArr select _j;
_r = _s - _c;
_r = abs (_r % 127);
if (_r > 0) then {
_seedArr set [_j, _r];
};
};
_dicLength = count _dic;
_hash = '';
{_hash = _hash + (_dic select [_x % _dicLength, 1]);} foreach _seedArr;
_hash = _seed + '.' + _hash;
_hash
};
MMC_fnc_hashVerify = {
private ['_str', '_hash', '_dic', '_dot', '_seed', '_verify'];
_str = [_this, 0, '', ['']] call BIS_fnc_param;
_hash = [_this, 1, '', ['']] call BIS_fnc_param;
_dic = [_this, 2, '0123456789abcdef', ['']] call BIS_fnc_param;
if (_hash == '') exitWith {false};
_dot = _hash find '.';
if (_dot == -1) exitWith {false};
_seed = _hash select [0, _dot];
_verify = [_str, _seed, _dic] call MMC_fnc_hashString;
_hash == _verify
};
systemChat 'Starting Hashing';
private ['_start', '_seed'];
MMC_fnc_randomGen =
{
_arr = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4'];
_gen = '';
_max = 8;
for '_i' from 0 to _max do {_gen = _gen + (_arr select (random ((count _arr)-1)));};
_gen
};
_start = diag_tickTime;
{
private ['_code', '_hash', '_check'];
_code = str (missionNamespace getVariable [_x, '']);
_seed = call MMC_fnc_randomGen;
_hash = [_code, _seed] call MMC_fnc_hashString;
_check = [_code, _hash] call MMC_fnc_hashVerify;
systemChat format['%1: %2 | %3', _x, _hash, _check];
diag_log format['%1: %2 | %3', _x, _hash, _check];
} foreach [
'EPOCH_clientInit',
'EPOCH_onEachFrame',
'EPOCH_masterLoop',
'EPOCH_client_rejectPlayer',
'EPOCH_clientRespawn',
'EPOCH_KeyDown'
];
systemChat format['Total Time: %1', (diag_tickTime - _start)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment