篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 Base 58编码(用于flic.kr短网址)相关的知识,希望对你有一定的参考价值。
/*
Function used to return flickr short url from a photo id.
example of usage
var shortFlickrURL:String = 'www.flic.kr/p/' + Base58Encoder.encode(Number('4725679319') );
/// returns www.flic.kr/p/8cAkPD
/// short url for this full url http://www.flickr.com/photos/ninjaparade/4725679319/
*/
package {
/**
* @author ninjaparade
*/
public class Base58Encoder {
public static function encode( num : Number ) : String
{
var alphabet : String = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ' ;
var base_count : int = alphabet.length;
var encode : String = "";
while(num >= base_count) {
var div : int = num / base_count;
var mod : int = (num - base_count * Math.round(div) );
encode = alphabet.charAt(mod) + encode;
num = Math.round(div);
}
if(num)
{
encode = alphabet.charAt(num) + encode;
}
return encode;
}
}
}
以上是关于ActionScript 3 Base 58编码(用于flic.kr短网址)的主要内容,如果未能解决你的问题,请参考以下文章