1
0
mirror of https://github.com/bitwarden/directory-connector synced 2025-12-16 08:14:01 +00:00

convert projects to netstandard lib & netcore app

This commit is contained in:
Kyle Spearrin
2017-10-24 17:13:56 -04:00
parent fef8bd1e00
commit 7d3ea444f4
23 changed files with 84 additions and 366 deletions

View File

@@ -14,14 +14,18 @@ namespace Bit.Core.Models
public EncryptedData(byte[] plainValue)
{
IV = RandomBytes();
#if NET461
Value = ProtectedData.Protect(plainValue, IV, DataProtectionScope.LocalMachine);
#endif
}
public EncryptedData(string plainValue)
{
var bytes = Encoding.UTF8.GetBytes(plainValue);
IV = RandomBytes();
#if NET461
Value = ProtectedData.Protect(bytes, IV, DataProtectionScope.LocalMachine);
#endif
}
public byte[] Value { get; set; }
@@ -29,12 +33,20 @@ namespace Bit.Core.Models
public byte[] Decrypt()
{
#if NET461
return ProtectedData.Unprotect(Value, IV, DataProtectionScope.LocalMachine);
#else
return new byte[0];
#endif
}
public string DecryptToString()
{
#if NET461
var bytes = ProtectedData.Unprotect(Value, IV, DataProtectionScope.LocalMachine);
#else
var bytes = new byte[0];
#endif
return Encoding.UTF8.GetString(bytes);
}