move aiid2regcode/regcode2aiid to core.tool
This commit is contained in:
parent
7bbcf69fe5
commit
27559f4824
19
index.js
19
index.js
@ -440,25 +440,6 @@ module.exports = {
|
|||||||
return require('crypto').createHash(hasher).update(data, inputEncoding).digest(outputEncoding)
|
return require('crypto').createHash(hasher).update(data, inputEncoding).digest(outputEncoding)
|
||||||
},
|
},
|
||||||
|
|
||||||
regcode2aiid(code) {
|
|
||||||
if (typeof code === 'string' && /^[a-zA-Z0-9]+$/.test(code)) {
|
|
||||||
const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz'
|
|
||||||
const base = 16367
|
|
||||||
code = code.toLowerCase()
|
|
||||||
let len = code.length
|
|
||||||
let num = 0
|
|
||||||
for (let i = 0; i < len; i++) {
|
|
||||||
num += alphabet.indexOf(code[i]) * Math.pow(alphabet.length, i)
|
|
||||||
}
|
|
||||||
let aiid = num / (base - alphabet.length) - base
|
|
||||||
if (aiid >= 0 && Number.isInteger(aiid)) {
|
|
||||||
// 允许 aiid===0:当第一个用户(aiid==1)登录时,需要一个系统默认的邀请码。
|
|
||||||
return aiid
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null
|
|
||||||
},
|
|
||||||
|
|
||||||
getUserEndLanIp(callback) {
|
getUserEndLanIp(callback) {
|
||||||
let recode = {};
|
let recode = {};
|
||||||
let RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
|
let RTCPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection;
|
||||||
|
Loading…
Reference in New Issue
Block a user