1
0
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:
Kyle Spearrin
2017-05-12 12:52:05 -04:00
parent 6fdcf2d6ba
commit b67918c2cc
3 changed files with 41 additions and 5 deletions

View File

@@ -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];