diff --git a/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs b/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs index 00ed14e2f..a3d37ea52 100644 --- a/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs +++ b/aspnet-core/framework/security/LINGYUN.Abp.Encryption.SM4/LINGYUN/Abp/Encryption/SM4/SM4StringEncryptionService.cs @@ -37,10 +37,9 @@ public class SM4StringEncryptionService : StringEncryptionService using var password = new Rfc2898DeriveBytes(passPhrase, salt); // 128-bit key var keyBytes = password.GetBytes(16); - var ivBytes = password.GetBytes(16); var cipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(new SM4Engine()), new Pkcs7Padding()); - cipher.Init(false, new ParametersWithIV(new KeyParameter(keyBytes), ivBytes)); + cipher.Init(false, new ParametersWithIV(new KeyParameter(keyBytes), Options.InitVectorBytes)); var decryptTextBytes = cipher.DoFinal(cipherTextBytes); @@ -61,10 +60,9 @@ public class SM4StringEncryptionService : StringEncryptionService using var password = new Rfc2898DeriveBytes(passPhrase, salt); // 128-bit key var keyBytes = password.GetBytes(16); - var ivBytes = password.GetBytes(16); var cipher = new PaddedBufferedBlockCipher(new CbcBlockCipher(new SM4Engine()), new Pkcs7Padding()); - cipher.Init(true, new ParametersWithIV(new KeyParameter(keyBytes), ivBytes)); + cipher.Init(true, new ParametersWithIV(new KeyParameter(keyBytes), Options.InitVectorBytes)); var decryptTextBytes = cipher.DoFinal(plainTextBytes);