descriptografar static method

String descriptografar(
  1. String texto
)

Implementation

static String descriptografar(String texto) {
  Map<String, String> chavevalor = _getKey(texto);
  texto = chavevalor['texto']!;
  String keyselecionada = chavevalor['key']!;

  final key = Key.fromUtf8(keyselecionada);
  final iv = IV.fromLength(16);

  final encrypter = Encrypter(AES(key, mode: AESMode.ecb));

  return encrypter.decrypt16(texto, iv: iv);

  /*String c = "";
  String result = "";
  int i;
  int pos;
  for (i = 0; i <= (texto.length / 2).truncate() - 1; i++) {
    pos = (i * 2);
    List<int> hexa = HEX.decode(texto.substring(pos, pos + 2));
    c = utf8.decode(hexa);

    if (key.length > 0) {
      pos = 1 + (i % key.length);
      c = utf8.decode([
        utf8.encode(key.substring(pos - 1, pos)).last ^ (utf8.encode(c).last)
      ]);
    }
    result = result + c;
  }
*/
  //return result;
}