From 149c16fef7429411d73f8a9617a28e6aea79f872 Mon Sep 17 00:00:00 2001 From: Luk Lu Date: Sat, 18 Mar 2023 08:03:53 +0800 Subject: [PATCH] rename aiidcode to haid --- coretool.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/coretool.js b/coretool.js index d792568..9ee6f06 100644 --- a/coretool.js +++ b/coretool.js @@ -171,7 +171,7 @@ module.exports = { * @return {*} * @memberof TICrypto */ - aiid_to_aiidcode (aiid) { + aiid_to_haid (aiid) { const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz' const base = 16367 let num = (aiid + base) * (base - alphabet.length) @@ -193,15 +193,15 @@ module.exports = { * @return {*} * @memberof TICrypto */ - aiidcode_to_aiid (code) { - if (typeof code === 'string' && /^[a-zA-Z0-9]+$/.test(code)) { + haid_to_aiid (haid) { + if (typeof haid === 'string' && /^[a-zA-Z0-9]+$/.test(haid)) { const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz' const base = 16367 - code = code.toLowerCase() - let len = code.length + haid = haid.toLowerCase() + let len = haid.length let num = 0 for (let i = 0; i < len; i++) { - num += alphabet.indexOf(code[i]) * Math.pow(alphabet.length, i) + num += alphabet.indexOf(haid[i]) * Math.pow(alphabet.length, i) } let aiid = num / (base - alphabet.length) - base if (aiid >= 0 && Number.isInteger(aiid)) { @@ -209,7 +209,7 @@ module.exports = { return aiid } } - return null // null 代表一切非法的regcode + return null // null 代表一切非法的 haid }, isEmpty (value) {