fix return the wrong value
This commit is contained in:
@@ -35,10 +35,13 @@ namespace Pilz.Cryptography
|
||||
byte[] bytes = TextEncoding.GetBytes(key);
|
||||
byte[] array = sha1CryptoServiceProvider.ComputeHash(bytes);
|
||||
|
||||
var output = new byte[checked(length - 1 + 1)];
|
||||
array.CopyTo(output, 0);
|
||||
var output = new byte[length];
|
||||
var lowerLength = Math.Min(array.Length, output.Length);
|
||||
|
||||
for (int i = 0; i < lowerLength; i++)
|
||||
output[i] = array[i];
|
||||
|
||||
return array;
|
||||
return output;
|
||||
}
|
||||
|
||||
private string EncryptData(string plaintext)
|
||||
@@ -63,7 +66,7 @@ namespace Pilz.Cryptography
|
||||
|
||||
public string Encrypt(string plainValue)
|
||||
{
|
||||
return EncryptData(plainValue);
|
||||
return EncryptData(plainValue ?? string.Empty);
|
||||
}
|
||||
|
||||
public string Decrypt(string encryptedValue)
|
||||
|
||||
Reference in New Issue
Block a user