System.Security.Cryptography.RSAOAEPKeyExchangeFormatter.CreateKeyExchange C# (CSharp) Method

CreateKeyExchange() public method

public CreateKeyExchange ( byte rgbData ) : byte[]
rgbData byte
return byte[]
        public override byte[] CreateKeyExchange(byte[] rgbData)
        {
            if (_rsaKey == null)
                throw new CryptographicUnexpectedOperationException(SR.Cryptography_MissingKey);

            return _rsaKey.Encrypt(rgbData, RSAEncryptionPadding.OaepSHA1);
        }

Same methods

RSAOAEPKeyExchangeFormatter::CreateKeyExchange ( byte rgbData, Type symAlgType ) : byte[]

Usage Example

		public void ExchangeMin() 
		{
			AsymmetricKeyExchangeFormatter keyex = new RSAOAEPKeyExchangeFormatter (key);
			byte[] M = { 0x01 };
			try {
				byte[] EM = keyex.CreateKeyExchange (M);
				AsymmetricKeyExchangeDeformatter keyback = new RSAOAEPKeyExchangeDeformatter (key);
				byte[] Mback = keyback.DecryptKeyExchange (EM);
				AssertEquals ("RSAOAEPKeyExchangeFormatter Min", M, Mback);
			}
			catch (CryptographicException ce) {
				// not supported by every version of Windows - Minimum: Windows XP
				Console.WriteLine (ce.Message + " (" + Environment.OSVersion.ToString () + ")");
			}
		}
All Usage Examples Of System.Security.Cryptography.RSAOAEPKeyExchangeFormatter::CreateKeyExchange