/// <summary> /// Configures keys to be encrypted with Windows DPAPI before being persisted to /// storage. /// </summary> /// <param name="builder">The <see cref="IDataProtectionBuilder"/>.</param> /// <param name="protectToLocalMachine">'true' if the key should be decryptable by any /// use on the local machine, 'false' if the key should only be decryptable by the current /// Windows user account.</param> /// <returns>A reference to the <see cref="IDataProtectionBuilder" /> after this operation has completed.</returns> /// <remarks> /// This API is only supported on Windows platforms. /// </remarks> public static IDataProtectionBuilder ProtectKeysWithDpapi(this IDataProtectionBuilder builder, bool protectToLocalMachine) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } Use(builder.Services, DataProtectionServiceDescriptors.IXmlEncryptor_Dpapi(protectToLocalMachine)); return(builder); }
/// <summary> /// Configures keys to be encrypted with Windows DPAPI before being persisted to /// storage. /// </summary> /// <param name="protectToLocalMachine">'true' if the key should be decryptable by any /// use on the local machine, 'false' if the key should only be decryptable by the current /// Windows user account.</param> /// <returns>The 'this' instance.</returns> /// <remarks> /// This API is only supported on Windows platforms. /// </remarks> public DataProtectionConfiguration ProtectKeysWithDpapi(bool protectToLocalMachine) { Use(DataProtectionServiceDescriptors.IXmlEncryptor_Dpapi(protectToLocalMachine)); return(this); }