Convert Uint8List to String with Dart

I guess this should do it:

String s = new String.fromCharCodes(inputAsUint8List);
var outputAsUint8List = new Uint8List.fromList(s.codeUnits);

Uint8List x;
Utf8Decoder().convert(x);

To answer the specific question. I haven't used cipher.process, and can't find the docs. But if it just returns raw bytes, then perhaps these would be best encoded as hexidecimal or base64.

Have a look at CryptoUtils.bytesToBase64, and CryptoUtils.bytesToHex.

To answer the general question in the title, if the Uint8List contains UTF8 text, then use UTF8.decode() from the dart:convert library. See the api docs.

import 'dart:convert';

main() {
  var encoded = UTF8.encode("Îñţérñåţîöñåļîžåţîờñ");
  var decoded = UTF8.decode([0x62, 0x6c, 0xc3, 0xa5, 0x62, 0xc3, 0xa6,
                           0x72, 0x67, 0x72, 0xc3, 0xb8, 0x64]);
}

String.fromCharCodes() takes a list of UTF-16 code units as input.

Also see LATIN1 which will behave the same as String.fromCharCodes when the input is < 0xFF.