"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Help = void 0; const dayjs = require("dayjs"); const crypto_1 = require("crypto"); exports.Help = { getSecondTimestamp() { return Math.floor(Date.now() / 1000); }, getRandomInt(min, max) { min = Math.ceil(min); max = Math.floor(max); return Math.floor(Math.random() * (max - min + 1)) + min; }, getFastHshPeriods() { return dayjs(Date.now()).format('YYYYMMDDHHmmss'); }, formatDate(date, template = 'YYYY-MM-DD HH:mm:ss') { if (typeof date == 'number' && date.toString().length == 10) { date *= 1000; } return dayjs(date).format(template); }, diffDays(date1, date2) { return dayjs(date1).endOf('day').diff(dayjs(date2).endOf('day'), 'day'); }, phpmymd5(input, action = 'EN') { const secretString = `5*j,.^&;?.%#@!`; if (!input) return ''; let md5code; let processingString; if (action === 'EN') { md5code = (0, crypto_1.createHash)('md5').update(input).digest('hex').substr(8, 10); processingString = input; } else { md5code = input.slice(-10); processingString = Buffer.from(input.slice(0, -10), 'base64').toString('binary'); } const key = (0, crypto_1.createHash)('md5') .update(md5code + secretString) .digest('hex'); const keyLength = key.length; let result = ''; for (let i = 0; i < processingString.length; i++) { const keyPos = i % keyLength; result += String.fromCharCode(processingString.charCodeAt(i) ^ key.charCodeAt(keyPos)); } if (action === 'DE') { const verificationHash = (0, crypto_1.createHash)('md5') .update(result) .digest('hex') .substr(8, 10); return verificationHash === md5code ? result : null; } else { return Buffer.from(result, 'binary').toString('base64') + md5code; } }, }; //# sourceMappingURL=help.js.map