mirror of
https://github.com/bitwarden/directory-connector
synced 2025-12-16 00:04:34 +00:00
store server password encrypted
This commit is contained in:
@@ -17,6 +17,13 @@ namespace Bit.Core.Models
|
||||
Value = ProtectedData.Protect(plainValue, IV, DataProtectionScope.CurrentUser);
|
||||
}
|
||||
|
||||
public EncryptedData(string plainValue)
|
||||
{
|
||||
var bytes = Encoding.UTF8.GetBytes(plainValue);
|
||||
IV = RandomBytes();
|
||||
Value = ProtectedData.Protect(bytes, IV, DataProtectionScope.CurrentUser);
|
||||
}
|
||||
|
||||
public byte[] Value { get; set; }
|
||||
public byte[] IV { get; set; }
|
||||
|
||||
@@ -25,6 +32,12 @@ namespace Bit.Core.Models
|
||||
return ProtectedData.Unprotect(Value, IV, DataProtectionScope.CurrentUser);
|
||||
}
|
||||
|
||||
public string DecryptToString()
|
||||
{
|
||||
var bytes = ProtectedData.Unprotect(Value, IV, DataProtectionScope.CurrentUser);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
private byte[] RandomBytes()
|
||||
{
|
||||
var entropy = new byte[16];
|
||||
|
||||
Reference in New Issue
Block a user