Esempio n. 1
0
        public byte[] Encrypt(byte[] bytes, string receiverPublicKey)
        {
            if (bytes == null)
            {
                bytes = new byte[0];
            }

            RsaEncryption rsa = new RsaEncryption(this._rsa.KeySize, receiverPublicKey);

            return(rsa.Encrypt(bytes));
        }
Esempio n. 2
0
        public void EncryptFile(RsaAesDecryptor decryptor, string file, string encryptedFile)
        {
            AesEncryption aes = new AesEncryption();
            RsaEncryption rsa = new RsaEncryption();

            _aesEncryptedKey = rsa.Encrypt(aes.Key, decryptor.PublicKey);
            _aesEncryptedIV  = rsa.Encrypt(aes.IV, decryptor.PublicKey);

            File.Delete(encryptedFile);
            aes.EncryptFile(file, encryptedFile);
        }
Esempio n. 3
0
        public byte[] Encrypt(string str, string receiverPublicKey)
        {
            if (str == null)
            {
                str = "";
            }

            RsaEncryption rsa = new RsaEncryption(this._rsa.KeySize, receiverPublicKey);

            return(rsa.Encrypt(System.Text.Encoding.Unicode.GetBytes(str)));
        }