Skip to content

Commit

Permalink
fix: correct hash position in decrypt function (#24)
Browse files Browse the repository at this point in the history
Fixes the "Padding is invalid and cannot be removed" error in the decrypt function by ensuring the correct hash position is used for decryption.

Issue #23
  • Loading branch information
diandsonc committed Aug 30, 2023
1 parent 7af8d5f commit 8f455e6
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CipherKey" Version="1.0.0" />
<PackageReference Include="CipherKey" Version="1.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CipherKey" Version="1.0.0" />
<PackageReference Include="CipherKey" Version="1.0.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="CipherKey" Version="1.0.0" />
<PackageReference Include="CipherKey" Version="1.0.1" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="CipherKey" Version="1.0.0" />
<PackageReference Include="CipherKey" Version="1.0.1" />
</ItemGroup>

</Project>
4 changes: 2 additions & 2 deletions src/CipherKey/CipherKey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
<ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>CipherKey</AssemblyName>
<AssemblyTitle>CipherKey</AssemblyTitle>
<AssemblyVersion>1.0.0</AssemblyVersion>
<AssemblyVersion>1.0.1</AssemblyVersion>
<Product>CipherKey Library</Product>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Diandson C. Ramos</Authors>
<Owners>Diandson C. Ramos</Owners>
<Copyright>Copyright (c) 2023 Diandson C. Ramos</Copyright>
Expand Down
4 changes: 2 additions & 2 deletions src/CipherKey/Utils/CipherKeyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public static string Decrypt(string encryptedText, string encryptionKey, string

using (Aes aesAlg = Aes.Create())
{
aesAlg.Key = Encoding.UTF8.GetBytes(encryptionKey[^32..]);
aesAlg.IV = Encoding.UTF8.GetBytes(encryptionIV[^16..]);
aesAlg.Key = Encoding.UTF8.GetBytes(encryptionKey[..32]);
aesAlg.IV = Encoding.UTF8.GetBytes(encryptionIV[..16]);
aesAlg.Padding = PaddingMode.ISO10126;

using (var decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV))
Expand Down

0 comments on commit 8f455e6

Please sign in to comment.