Example #1
0
        public async Task <BigInt.BigInt[]> Encrypt(string text, PublicKey publicKey, IProgress <double> progress = default)
        {
            var textBytes = StringUtils.ConvertToNumbers(text.ToLower(), _alphabet);
            var encrypted = new BigInt.BigInt[textBytes.Length];

            await Task.Run(() =>
            {
                for (var i = 0; i < textBytes.Length; i++)
                {
                    encrypted[i] = RsaEncrypting.EncryptNumber(textBytes[i], publicKey);
                    progress?.Report(100.0 / text.Length *i);
                }

                progress?.Report(100);
            });

            return(encrypted);
        }
Example #2
0
 public void NumberEncryptionTest(int number, int encrypted) =>
 Assert.AreEqual((BigInt.BigInt)encrypted, RsaEncrypting.EncryptNumber(number, PublicKey));