asymmetricCipher static method

List<int> asymmetricCipher({
  1. required List<int> data,
  2. required int? publicKey,
  3. required int? modulo,
})

Encrypt your data without handing a shared encryption/decryption key or generation seed, which is the basic asymetric encryption purpose.

Implementation

static List<int> asymmetricCipher({required List<int> data,required int? publicKey,required int? modulo}){
  List<int> cipheredData = [];
  for(int i = 0;i < data.length; i++){
    if(data[i] <= modulo!){
      //Encrypt and add
      cipheredData.add(data[i].modPow(publicKey!, modulo));
      if(cipheredData[i] == double.infinity){
        throw CipherError.bigPassword;
      }
    }else{
      throw CipherError.smallPassword;
    }
  }
  //Return the encrypted data
  return cipheredData;
}