CapyKit/Docs/api/CapyKit.IPasswordAlgorithm.md

85 lines
2.5 KiB
Markdown

# <a id="CapyKit_IPasswordAlgorithm"></a> Interface IPasswordAlgorithm
Namespace: [CapyKit](CapyKit.md)
Assembly: CapyKit.dll
Defines the contract for password encryption algorithms.
```csharp
public interface IPasswordAlgorithm
```
#### Extension Methods
[ObjectExtensions.UpdateProperties<IPasswordAlgorithm\>\(IPasswordAlgorithm, IPasswordAlgorithm\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_\_1\_\_\_0\_\_\_0\_),
[ObjectExtensions.UpdateProperties\(object, object\)](CapyKit.Extensions.ObjectExtensions.md\#CapyKit\_Extensions\_ObjectExtensions\_UpdateProperties\_System\_Object\_System\_Object\_)
## Properties
### <a id="CapyKit_IPasswordAlgorithm_AlgorithmName"></a> AlgorithmName
Gets the name of the algorithm.
```csharp
string AlgorithmName { get; }
```
#### Property Value
[string](https://learn.microsoft.com/dotnet/api/system.string)
## Methods
### <a id="CapyKit_IPasswordAlgorithm_Compare_System_String_System_Byte___System_Object___"></a> Compare\(string, byte\[\], params object\[\]\)
Compares the given plaintext password with an encrypted value using PBKDF2 algorithm.
```csharp
bool Compare(string password, byte[] encryptedValue, params object[] args)
```
#### Parameters
`password` [string](https://learn.microsoft.com/dotnet/api/system.string)
The plaintext password to compare.
`encryptedValue` [byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]
The encrypted value to compare against.
`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[\]
Additional arguments for the encryption process, such as salt and length.
#### Returns
[bool](https://learn.microsoft.com/dotnet/api/system.boolean)
True if the given <code class="paramref">password</code> matches the <code class="paramref">encryptedValue</code>,
false if they are different.
### <a id="CapyKit_IPasswordAlgorithm_Encrypt_System_String_System_Object___"></a> Encrypt\(string, params object\[\]\)
Encrypts the given password using a defined algorithm.
```csharp
byte[] Encrypt(string password, params object[] args)
```
#### Parameters
`password` [string](https://learn.microsoft.com/dotnet/api/system.string)
The plaintext password.
`args` [object](https://learn.microsoft.com/dotnet/api/system.object)\[\]
Additional arguments for the encryption process, such as salt and length.
#### Returns
[byte](https://learn.microsoft.com/dotnet/api/system.byte)\[\]
A byte array with the hashed <code class="paramref">password</code>.