Пример #1
0
        private void Encrypt()
        {
            try
            {
                RSAx rsax = RSAx.CreateFromXML(Key, ModSize);
                rsax.RSAxHashAlgorithm = HashAlgorithm;

                byte[] ct = rsax.Encrypt(Encoding.UTF8.GetBytes(TextPlain), InvertPPK, UseOAEP);
                TextCrypt = string.Join("\r\n", GetChunks(Convert.ToBase64String(ct), 50));
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception while Encryption: " + ex.Message);
            }
        }
Пример #2
0
        private void Decrypt()
        {
            try
            {
                RSAx rsax = RSAx.CreateFromXML(Key, ModSize);
                rsax.RSAxHashAlgorithm = HashAlgorithm;

                byte[] raw = Convert.FromBase64String(TextCrypt.Replace("\r", "").Replace("\n", ""));

                byte[] pt = rsax.Decrypt(raw, InvertPPK, UseOAEP);
                TextPlain = Encoding.UTF8.GetString(pt);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception while Decryption: " + ex.Message);
            }
        }