textDecryption static method
Decryption cipherText and extract key from it .
Implementation
static String textDecryption(String cipherText) {
// Setup letter to encryption and decryption
LettersInit.instance.setupLetters();
List<String> cipherList = cipherText.split("");
String firstLetter = cipherList.first;
String lastLetter = cipherList.last;
int firstInt = LettersInit.instance.lettersWithStringKey[firstLetter] ?? 0;
int secInt = LettersInit.instance.lettersWithStringKey[lastLetter] ?? 0;
int length = firstInt + secInt;
cipherList.removeAt(0);
cipherList.removeLast();
cipherText = cipherList.join();
// extract key from Cipher Text
String key = ExtractKey.extractKey(cipherText);
// get cipher text without key
cipherText = ExtractKey.extractCipherWithoutKey(cipherText);
// convert Cipher Text ( String ) to Cipher Text ( List<int> )
List<int> cipherTextAsInt = _convertCipherToInt(cipherText);
// Decryption Cipher Text List<Int>
List<int> plainInts = [];
int i = 0;
KeyModel keyModel = GenerateKey.getFullKey(key);
while (i < (keyModel.key) + (keyModel.key % 263)) {
plainInts = _convertCipherListIntToPlainListInt(
i == 0 ? cipherTextAsInt : plainInts, key, length);
++i;
}
// Convert Plain List<int> to readable String
String plainText = convertPlainIntToString(plainInts);
return plainText;
}