fix return the wrong value

This commit is contained in:
2021-03-25 13:24:04 +01:00
parent 6871d6952f
commit 3376fecd12
3 changed files with 20 additions and 17 deletions

View File

@@ -11,20 +11,19 @@ namespace Pilz.Cryptography
public class SecureString
{
public static ICrypter DefaultCrypter { get; set; }
[JsonIgnore]
public ICrypter Crypter { get; set; }
[JsonProperty]
public string EncryptedValue { get; set; }
[JsonIgnore]
public string Value
{
get => GetCrypter().Decrypt(EncryptedValue);
get => GetCrypter()?.Decrypt(EncryptedValue);
set => EncryptedValue = GetCrypter().Encrypt(value);
}
[JsonConstructor]
private SecureString(JsonConstructorAttribute dummyAttribute)
{
}
public SecureString() :
this(string.Empty, true)
{
@@ -73,7 +72,7 @@ namespace Pilz.Cryptography
public static implicit operator string(SecureString value) => value?.Value;
public static implicit operator SecureString(string value) => new SecureString(value, false);
public static bool operator ==(SecureString left, SecureString right) => left.EncryptedValue == right.EncryptedValue;
public static bool operator !=(SecureString left, SecureString right) => left.EncryptedValue != right.EncryptedValue;
public static bool operator ==(SecureString left, SecureString right) => left?.EncryptedValue == right?.EncryptedValue;
public static bool operator !=(SecureString left, SecureString right) => left?.EncryptedValue != right?.EncryptedValue;
}
}