INNER CODE UNIT · TypeScript
Utils
xiangsx/gpt4free-ts · model/ails/index.ts:34
class Utils {
static hash(json_data: { t: number; m: string }): string {
const secretKey: number[] = [
79, 86, 98, 105, 91, 84, 80, 78, 123, 83, 35, 41, 99, 123, 51, 54, 37, 57,
63, 103, 59, 117, 115, 108, 41, 67, 76,
];
const base_string: string = `${json_data['t']}:${json_data['m']}:'WI,2rU#_r:r~aF4aJ36[.Z(/8Rv93Rf':${json_data['m'].length}`;
return createHash('sha256').update(base_string).digest('hex');
}
static format_timestamp(timestamp: number): string {
const e = timestamp;
const n = e % 10;
const r = n % 2 === 0 ? n + 1 : n;
return String(e - n + r);
}