xorCode static method

String xorCode(
  1. String res,
  2. String key
)

XOR symmetric encryption

Implementation

static String xorCode(String res, String key) {
  List<String> keyList = key.split(',');
  List<int> codeUnits = res.codeUnits;
  List<int> codes = [];
  for (int i = 0, length = codeUnits.length; i < length; i++) {
    int code = codeUnits[i] ^ int.parse(keyList[i % keyList.length]);
    codes.add(code);
  }
  return String.fromCharCodes(codes);
}