diff --git a/Encrypt/AesEncryption/AesEncryption.cs b/Encrypt/AesEncryption/AesEncryption.cs index 4568e20..532e1f4 100644 --- a/Encrypt/AesEncryption/AesEncryption.cs +++ b/Encrypt/AesEncryption/AesEncryption.cs @@ -27,10 +27,11 @@ public byte[] AesEncrypt(string data, string secretKey, string iv) public byte[] AesDecrypt(string data, string secretKey, string iv) { NullChecks(data, secretKey, iv); - var convertedKeys = ConvertKeysToBytes(secretKey, iv); + //var convertedKeys = ConvertKeysToBytes(secretKey, iv); - var aesKey = convertedKeys.Item1; - var aesIv = convertedKeys.Item2; + var (aesKey, aesIv) = ConvertKeysToBytesAndGetKeys(secretKey, iv); + //var aesKey = convertedKeys.Item1; + //var aesIv = convertedKeys.Item2; var aesData = data.HexadecimalStringToByteArray(); return DecryptAES(aesData, aesKey, aesIv); @@ -101,6 +102,13 @@ private void NullChecks(string data, string secretKey, string iv) return (secret, iv); } + + private (byte[], byte[]) ConvertKeysToBytesAndGetKeys(string secretKey, string iv) + { + var convertedKeys = ConvertKeysToBytes(secretKey, iv); + + return (convertedKeys.Item1, convertedKeys.Item2); + } private void NullChecks(string data, string secretKey) { if (data == null || data.Length <= 0)