adaptivePasswordGeneration static method
Generate a password capable of cyphering your data to avoid throwing errors. All numbers smaller than the generated will fail to cipher all the data
Implementation
static int adaptivePasswordGeneration(List<int> data){
int biggestInteger = 0;
data.forEach((thisNumber) {
if(biggestInteger < thisNumber){
biggestInteger = thisNumber;
}
});
//Pick a random factor
int p = biggestInteger;
int q = 1;
//Zeros to make the password valid when it's split in the middle by CipherGen
String middleZeroes = "";
int pLength = p.toString().length;
if(pLength > 0){
for(int i = 0; i < (pLength - 1); i++){
middleZeroes += "0";
}
}
String concatenatedPQ = '$p$middleZeroes$q';
int password = int.parse(concatenatedPQ);
return password;
}