# 本地SM4解密文件

本地SM4解密文件:可调用SDK的SM4Utils包实现本文件SM4算法对称解密。

# 一、本地SM4解密文件

  • 使用本地SDK SM4Utils包中的fileDecryptWithSm4方法实现本地文件解密

# 1、方法入参

名称 类型 是否必须 描述
file File 待解密文件
decFilePath String 解密后文件路径
symKey byte[] 密钥
workMode SymmetricWorkMode 对称加解密工作模式(ECB或CBC)
iv String 初始向量(CBC模式需传入,不传为00000000000000000000000000000000)

# 2、示例


        String encFilePath = "xxx";
        File encFile = new File(encFilePath);
        
        String decFilePath = "xxx";
        
        String symKeyStr = "xxxxxxxxxxxxx";
        byte[] symKey = ByteUtils.fromHexString(key);
        
        String iv = "00000000000000000000000000000000";
        
        File decFile = SM4Utils.fileDecryptWithSm4(encFile,decFilePath,symKey, SymmetricWorkMode.CBC,vi);
最后更新于: 8/23/2022, 3:34:07 PM