Mono.Security.Cryptography.RSAManaged.EncryptValue C# (CSharp) Method

EncryptValue() public method

public EncryptValue ( byte rgb ) : byte[]
rgb byte
return byte[]
		public override byte[] EncryptValue (byte[] rgb) 
		{
			if (m_disposed)
				throw new ObjectDisposedException ("public key");

			if (!keypairGenerated)
				GenerateKeyPair ();

			BigInteger input = new BigInteger (rgb);
			BigInteger output = input.ModPow (e, n);
			// it's sometimes possible for the results to be a byte short
			// and this can break some software (see #79502) so we 0x00 pad the result
			byte[] result = GetPaddedValue (output, (KeySize >> 3));
			// zeroize value
			input.Clear ();	
			output.Clear ();
			return result;
		}

Usage Example

コード例 #1
0
ファイル: RSAManagedTest.cs プロジェクト: REALTOBIZ/mono
		private void EncryptDecrypt (string msg, RSAManaged rsa) 
		{
			RSAParameters param = rsa.ExportParameters (false);

			byte[] data = { 0xFF, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 };
			// we don't need the private key to encrypt
			RSAManaged pubkey = new RSAManaged ();
			pubkey.ImportParameters (param);
			byte[] enc = pubkey.EncryptValue (data);

			byte[] dec = rsa.DecryptValue (enc);
			// note: the decrypted value is now right padded with zeros
			Assert.IsTrue (BitConverter.ToString (dec).EndsWith (BitConverter.ToString (data)), msg);
		}
All Usage Examples Of Mono.Security.Cryptography.RSAManaged::EncryptValue