encrypt static method

String encrypt(
  1. String key,
  2. String value
)

Encodes String

Implementation

static String encrypt(String key, String value) {
  if (key.isEmpty) {
    return value;
  }
  List<String> keyList =
      key.runes.map((rune) => String.fromCharCode(rune)).toList();
  int currentKeyPos = 0;
  String result = "";
  List<String> tmp =
      value.runes.map((rune) => String.fromCharCode(rune)).toList();
  int counter = 0;
  for (String s in tmp) {
    result += _calculateStringFromKey(keyList[currentKeyPos], s, key);
    if (counter < tmp.length - 1) {
      result = result + "a";
    }
    currentKeyPos++;
    if (currentKeyPos >= keyList.length) {
      currentKeyPos = 0;
    }
    counter++;
  }
  return result;
}