Coverting an int to a different base. php, .NET
Hey I have seen sites that instead of an int show you a string.
For example d2fr4st == 147392525
and d2fr4ss == 147392524
. What base is this? And how can I do the sa开发者_JAVA百科me conversion in php and .NET?
At the moment converting from 147392524
to d2fr4ss
would be most useful.
For .Net there's an implementation here: base36
UInt64ToBase36(147392524); //2FR4SS
UInt64ToBase36(147392525); //2FR4ST
Like VolkerK said I'd assume the d is an identifier perhaps just to show that the string is a base36 number if it's using more bases.
echo base_convert(147392524 , 10, 36), "\n";
prints 2fr4ss
. The leading d might be an identifier or some kind of checksum ...or simply a typo?
see http://docs.php.net/base_convert
It's probably base64. PHP has base64_encode, ASP.NET has Convert.ToBase64String
精彩评论