rename aiidcode to haid
This commit is contained in:
parent
d2e1984ffc
commit
149c16fef7
14
coretool.js
14
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) {
|
||||
|
Loading…
Reference in New Issue
Block a user