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 {*}
 | 
					   * @return {*}
 | 
				
			||||||
   * @memberof TICrypto
 | 
					   * @memberof TICrypto
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  aiid_to_aiidcode (aiid) {
 | 
					  aiid_to_haid (aiid) {
 | 
				
			||||||
    const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz'
 | 
					    const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz'
 | 
				
			||||||
    const base = 16367
 | 
					    const base = 16367
 | 
				
			||||||
    let num = (aiid + base) * (base - alphabet.length)
 | 
					    let num = (aiid + base) * (base - alphabet.length)
 | 
				
			||||||
@ -193,15 +193,15 @@ module.exports = {
 | 
				
			|||||||
   * @return {*}
 | 
					   * @return {*}
 | 
				
			||||||
   * @memberof TICrypto
 | 
					   * @memberof TICrypto
 | 
				
			||||||
   */
 | 
					   */
 | 
				
			||||||
  aiidcode_to_aiid (code) {
 | 
					  haid_to_aiid (haid) {
 | 
				
			||||||
    if (typeof code === 'string' && /^[a-zA-Z0-9]+$/.test(code)) {
 | 
					    if (typeof haid === 'string' && /^[a-zA-Z0-9]+$/.test(haid)) {
 | 
				
			||||||
      const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz'
 | 
					      const alphabet = 'e5fcdg3hqa4b1n0pij2rstuv67mwx89klyz'
 | 
				
			||||||
      const base = 16367
 | 
					      const base = 16367
 | 
				
			||||||
      code = code.toLowerCase()
 | 
					      haid = haid.toLowerCase()
 | 
				
			||||||
      let len = code.length
 | 
					      let len = haid.length
 | 
				
			||||||
      let num = 0
 | 
					      let num = 0
 | 
				
			||||||
      for (let i = 0; i < len; i++) {
 | 
					      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
 | 
					      let aiid = num / (base - alphabet.length) - base
 | 
				
			||||||
      if (aiid >= 0 && Number.isInteger(aiid)) {
 | 
					      if (aiid >= 0 && Number.isInteger(aiid)) {
 | 
				
			||||||
@ -209,7 +209,7 @@ module.exports = {
 | 
				
			|||||||
        return aiid
 | 
					        return aiid
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return null // null 代表一切非法的regcode
 | 
					    return null // null 代表一切非法的 haid
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  isEmpty (value) {
 | 
					  isEmpty (value) {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user