src/openSourceC.DotNetLibrary.Core/XmlSerialize.cs
/// <summary>
///		Decrypts and deserializes the specified object using the specified key and
///		initialization vector and returns a base 64 encoded string of the encrypted data.
/// </summary>
/// <typeparam name="TObject">The type of the object to deserialize.</typeparam>
/// <typeparam name="TSymmetricAlgorithm">The type of the cryptographic object used to
///		perform the symmetric algorithm.</typeparam>
/// <param name="base64XmlString">The string to be decrypted and deserialized.</param>
/// <param name="key">Encryption key.</param>
/// <param name="iv">Encryption initialization vector.</param>
/// <returns>
///		An object of type <typeparamref name="TObject"/>.
/// </returns>
Decrypts and deserializes the specified object using the specified key and
initialization vector and returns a base 64 encoded string of the encrypted data.
Decrypts and deserializes the specified object using the specified key and initialization vector and returns a base 64 encoded string of the encrypted data .
public static TObject? DecryptFromBase64String<TObject, TSymmetricAlgorithm>(string base64XmlString, byte[] key, byte[] iv)
			where TSymmetricAlgorithm : SymmetricAlgorithm, new()
		{
#if DEBUG
			try
			{
#endif
				using (MemoryStream stream = new MemoryStream())
				{
					Encryption.DecryptFromBase64String<TSymmetricAlgorithm>(stream, base64XmlString, key, iv);
#if DIAGNOSTICS
					Debug.WriteLine($"Decrypted XML: {(new UTF8Encoding()).GetString(stream.ToArray())}\n");
#endif
					stream.Seek(0, SeekOrigin.Begin);
					XmlSerializer serializer = new XmlSerializer(typeof(TObject));
					return (TObject?)serializer.Deserialize(stream);
				}
#if DEBUG
			}
			catch (Exception)
			{
				throw;
			}
#endif
		}
public static TObject ? DecryptFromBase64String < TObject , TSymmetricAlgorithm > ( string base64XmlString , byte [ ] key , byte [ ] iv ) where TSymmetricAlgorithm : SymmetricAlgorithm , new ( ) { if DEBUG try { endif using ( MemoryStream stream = new MemoryStream ( ) ) { Encryption . DecryptFromBase64String < TSymmetricAlgorithm > ( stream , base64XmlString , key , iv ) ; if DIAGNOSTICS Debug . WriteLine ( $" Decrypted XML:  { ( new UTF8Encoding ( ) ) . GetString ( stream . ToArray ( ) ) } \n " ) ; endif stream . Seek ( 0 , SeekOrigin . Begin ) ; XmlSerializer serializer = new XmlSerializer ( typeof ( TObject ) ) ; return ( TObject ? ) serializer . Deserialize ( stream ) ; } if DEBUG } catch ( Exception ) { throw ; } endif }
Decrypts and deserializes the specified object using the specified key and
initialization vector and returns a base 64 encoded string of the encrypted data.
Decrypts and deserializes the specified object using the specified key and initialization vector and returns a base 64 encoded string of the encrypted data .
An object of type .
An object of type .
base64XmlString
string
The string to be decrypted and deserialized.
The string to be decrypted and deserialized .
key
byte[]
None
iv
byte[]
Encryption initialization vector.
Encryption initialization vector .
typeparam
The type of the object to deserialize.
The type of the object to deserialize .
typeparam
The type of the cryptographic object used to
perform the symmetric algorithm.
The type of the cryptographic object used to perform the symmetric algorithm .