cypherEncrypt function
Encrypts a plain string using substitution cipher with step control. Works directly on UTF-8, no Base64 involved.
Implementation
String cypherEncrypt(
String input, {
String sequence = defaultSequence,
int steps = 1,
}) {
final encrypted = input.split('').map((char) {
final idx = sequence.indexOf(char);
if (idx == -1) {
// char not in sequence -> leave unchanged
return char;
}
return sequence[(idx + steps) % sequence.length];
}).join();
return encrypted;
}