国钥 SM3 的 Java 程序实现 摘 要SM3 算法是我国自主研发的 hash 算法。本文将对 SM3 算法的加密原理及各个过程进行解析,并使用 java 语言设计程序实现 SM3算法,将 SM3 算法的各个流程通过 java 函数进行实现,包括数据填充,分组和迭代压缩等。在这个过程中,通过 SM3 加密过程中存储数据所使用的 java 数据类型不同,设计出两种不同的 SM3 算法java 实现:SM3-String 方式,SM3-BigInteger 方式。并对两种方式的优缺点进行分析。最后将设计出来的 SM3 加密程序与 java 语言自带的其他杂凑算法(MD5,SHA-256)实现进行对比,比较它们的运行效率。【关键词】hash 算法;国钥 SM3;java 程序设计; AbstractSM3 algorithm is a hash algorithm independently developed in China. This paper will analyze the encryption principle and each process of Sm3 algorithm, and use java language to design programs to realize SM3 algorithm, and implement each process of Sm3 algorithm through Java functions, including data filling, grouping and iterative compression. In this process, through the different Java data types used to store data in the SM3 encryption process, two different SM3 algorithm java implementations are designed: SM3 string mode and SM3 BigInteger mode. The advantages and disadvantages of the two methods are analyzed. Finally, the SM3 encryption program designed is compared with other hash algorithms (MD5, SHA-256) of Java language, and their running efficiency is compared. [Key words] hash algorithm; national key SM3; Java programming; 目 录目录第一章 绪论........................................................................................................11.1 研究背景与意义...................................................................................11.2 本文的总体内容...................................................................................2第二章 SM3 算法过程解析.......................................................................