Decode base32 enchants in PHP
<?php $enchantNames = array( 0 => "PROTECTION_ENVIRONMENTAL", 1 => "PROTECTION_FIRE", 2 => "PROTECTION_FALL", 3 => "PROTECTION_EXPLOSIONS", 4 => "PROTECTION_PROJECTILE", 5 => "OXYGEN", 6 => "WATER_WORKER", 16 => "DAMAGE_ALL", 17 => "DAMAGE_UNDEAD", 18 => "DAMAGE_ARTHROPODS", 19 => "KNOCKBACK", 20 => "FIRE_ASPECT", 21 => "LOOT_BONUS_MOBS", 32 => "DIG_SPEED", 33 => "SILK_TOUCH", 34 => "DURABILITY", 35 => "LOOT_BONUS_BLOCKS", 48 => "ARROW_DAMAGE", 49 => "ARROW_KNOCKBACK", 50 => "ARROW_FIRE", 51 => "ARROW_INFINITE", ); function getEnchants($base32) { $enchants = array(); $testNum = base_convert( $base32, 32, 10 ); while (strlen($testNum) % 3 != 0){ $testNum = "0".$testNum; } for ($i = 0; $i < strlen($testNum) / 3; $i++) { $item = substr($testNum, $i * 3, 3); $eID=substr($item, 0,2); $level=substr($item,2,1); array_push($enchants, array($eID, $level)); } return $enchants; } $base32 = "a7e9vd"; //Your input $enchants = getEnchants($base32); for ($i = 0; $i < count($enchants); $i++) { $enchant = $enchants[$i]; $eID = $enchant[0]; $level = $enchant[1]; $eName = $enchantNames[$eID]; echo $eName." " .$level ."<br/>\n"; } ?>
a7e9vd returns:
DURABILITY 3 LOOT_BONUS_BLOCKS 3 DIG_SPEED 5
Also dont forget about changing the level # into roman numerals, 1 = I, 2 = II, 3 = III, 4 = IV, etc...
I just found out about this page right now, but my method was to split (str_split) each 3 characters of XXYXXYXXY into an array (result: [XXY] - [XXY] - [XXY]), and then split each one of those by two characters (result: [XX, Y] - [XX, Y] - [XX, Y]). Then the first part (XX) would match the array with the names, the other part (Y) would match an array for the roman numerals, all depending on how many arrays there are, in this example: 3.