# encode static method

String encode(

1. Uint8List bytesList, {
2. Encoding encoding = Encoding.standardRFC4648,

})

Takes in a Uint8List converts it to a Uint8List so that I can run bit operations on it, then outputs a String representation of the base32.

## Implementation

    static String encode(Uint8List bytesList,
        {Encoding encoding = Encoding.standardRFC4648}) {
      var base32Chars = EncodingUtils.getChars(encoding);
      var i = 0;
      var count = (bytesList.length ~/ 5) * 5;
      var base32str = '';
      while (i < count) {
        var v1 = bytesList[i++];
        var v2 = bytesList[i++];
        var v3 = bytesList[i++];
        var v4 = bytesList[i++];
        var v5 = bytesList[i++];

        base32str += base32Chars[v1 >> 3] +
            base32Chars[(v1 << 2 | v2 >> 6) & 31] +
            base32Chars[(v2 >> 1) & 31] +
            base32Chars[(v2 << 4 | v3 >> 4) & 31] +
            base32Chars[(v3 << 1 | v4 >> 7) & 31] +
            base32Chars[(v4 >> 2) & 31] +
            base32Chars[(v4 << 3 | v5 >> 5) & 31] +
            base32Chars[v5 & 31];
      }

      var remain = bytesList.length - count;
      if (remain == 1) {
        var v1 = bytesList[i];
        base32str += base32Chars[v1 >> 3] + base32Chars[(v1 << 2) & 31];
        if (EncodingUtils.getPadded(encoding)) {
          base32str += '======';
        }
      } else if (remain == 2) {
        var v1 = bytesList[i++];
        var v2 = bytesList[i];
        base32str += base32Chars[v1 >> 3] +
            base32Chars[(v1 << 2 | v2 >> 6) & 31] +
            base32Chars[(v2 >> 1) & 31] +
            base32Chars[(v2 << 4) & 31];
        if (EncodingUtils.getPadded(encoding)) {
          base32str += '====';
        }
      } else if (remain == 3) {
        var v1 = bytesList[i++];
        var v2 = bytesList[i++];
        var v3 = bytesList[i];
        base32str += base32Chars[v1 >> 3] +
            base32Chars[(v1 << 2 | v2 >> 6) & 31] +
            base32Chars[(v2 >> 1) & 31] +
            base32Chars[(v2 << 4 | v3 >> 4) & 31] +
            base32Chars[(v3 << 1) & 31];
        if (EncodingUtils.getPadded(encoding)) {
          base32str += '===';
        }
      } else if (remain == 4) {
        var v1 = bytesList[i++];
        var v2 = bytesList[i++];
        var v3 = bytesList[i++];
        var v4 = bytesList[i];
        base32str += base32Chars[v1 >> 3] +
            base32Chars[(v1 << 2 | v2 >> 6) & 31] +
            base32Chars[(v2 >> 1) & 31] +
            base32Chars[(v2 << 4 | v3 >> 4) & 31] +
            base32Chars[(v3 << 1 | v4 >> 7) & 31] +
            base32Chars[(v4 >> 2) & 31] +
            base32Chars[(v4 << 3) & 31];
        if (EncodingUtils.getPadded(encoding)) {
          base32str += '=';
        }
      }
      return base32str;
    }