Created
August 25, 2020 06:31
-
-
Save tianyk/c819b5bf0c2062881daa244bf353f896 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function encode(id) { | |
return ('' + parseInt(id) * 71) | |
.split('') | |
.map(v => parseInt(v) + 65) | |
.map(code => String.fromCharCode(code)) | |
.join(''); | |
} | |
function decode(code) { | |
return parseInt(code.split('').map(char => char.charCodeAt(0) - 65).join('')) / 71; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment