xorCode static method

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

异或对称加密

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);
}