encode method

String encode(
  1. int dec
)

Implementation

String encode(int dec) {
  int mod = 64;
  int count = dec;
  List<int> hexList = [];
  if(count == 0){
    return _asciiTo64(count);
  }
  for (; count > 0;) {
    var ans1 = count / mod;
    var mod1 = ans1.round();
    var ans = count - (mod1 * mod);
    if (ans < 0) {
      mod1 -= 1;
      ans = count - ((mod1) * mod);
    }
    count = mod1;
    hexList.add(ans);
  }
  int length = hexList.length - 1;
  String hex = '';
  for (int i = length; i >= 0; i--) {
    var num = hexList[i];
    if (num < mod) {
      hex += _asciiTo64(num);
    }
  }

  return hex;
}