public static CopyWithNewPassword ( |
||
key | The PgpSecretKey to be copied. | |
oldPassPhrase | char | The current password for the key. |
newPassPhrase | char | The new password for the key. |
newEncAlgorithm | SymmetricKeyAlgorithmTag | The algorithm to be used for the encryption. |
rand | Source of randomness. | |
Résultat |
public static PgpSecretKeyRing CopyWithNewPassword(PgpSecretKeyRing ring, char[] oldPassPhrase, char[] newPassPhrase, SymmetricKeyAlgorithmTag newEncAlgorithm, SecureRandom rand) { global::System.Collections.IList list = Platform.CreateArrayList(((global::System.Collections.ICollection)ring.keys).get_Count()); global::System.Collections.IEnumerator enumerator = ring.GetSecretKeys().GetEnumerator(); try { while (enumerator.MoveNext()) { PgpSecretKey pgpSecretKey = (PgpSecretKey)enumerator.get_Current(); if (pgpSecretKey.IsPrivateKeyEmpty) { list.Add((object)pgpSecretKey); } else { list.Add((object)PgpSecretKey.CopyWithNewPassword(pgpSecretKey, oldPassPhrase, newPassPhrase, newEncAlgorithm, rand)); } } } finally { global::System.IDisposable disposable = enumerator as global::System.IDisposable; if (disposable != null) { disposable.Dispose(); } } return(new PgpSecretKeyRing(list, ring.extraPubKeys)); }
/// <summary> /// Return a copy of the passed in secret key ring, with the master key and sub keys encrypted /// using a new password and the passed in algorithm. /// </summary> /// <param name="ring">The <c>PgpSecretKeyRing</c> to be copied.</param> /// <param name="oldPassPhrase">The current password for key.</param> /// <param name="newPassPhrase">The new password for the key.</param> /// <param name="newEncAlgorithm">The algorithm to be used for the encryption.</param> /// <param name="rand">Source of randomness.</param> public static PgpSecretKeyRing CopyWithNewPassword( PgpSecretKeyRing ring, char[] oldPassPhrase, char[] newPassPhrase, SymmetricKeyAlgorithmTag newEncAlgorithm, SecureRandom rand) { IList newKeys = Platform.CreateArrayList(ring.keys.Count); foreach (PgpSecretKey secretKey in ring.GetSecretKeys()) { newKeys.Add(PgpSecretKey.CopyWithNewPassword(secretKey, oldPassPhrase, newPassPhrase, newEncAlgorithm, rand)); } return(new PgpSecretKeyRing(newKeys, ring.extraPubKeys)); }