Created
April 11, 2015 17:01
-
-
Save loon3/d698d02ee17c3505e774 to your computer and use it in GitHub Desktop.
Counterparty Asset ID to Asset Name
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 assetid(asset_name) { | |
asset_name.toUpperCase(); | |
if(asset_name != "XCP"){ | |
var b26_digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'; | |
var name_array = asset_name.split(""); | |
var n = 0; | |
for (i = 0; i < name_array.length; i++) { | |
n *= 26; | |
n += b26_digits.indexOf(name_array[i]); | |
} | |
var asset_id = n; | |
} else { | |
var asset_id = 1; | |
} | |
return asset_id; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment