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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user