資源簡介
本壓縮包包括:
SM3.java
SM3密碼雜湊算法.pdf
國密辦發布SM3算法的網址.txt
也就是java實現,和國密辦發布的SM3算法pdf。

代碼片段和文件信息
import?org.apache.commons.logging.Log;
import?org.apache.commons.logging.LogFactory;
import?java.io.ByteArrayOutputStream;
import?java.io.IOException;
import?java.math.BigInteger;
import?java.util.Arrays;
public?class?SM3?{
????private?static?Log?logger?=?LogFactory.getLog(SM3.class);
????private?static?char[]?chars?=?{‘0‘?‘1‘?‘2‘?‘3‘?‘4‘?‘5‘?‘6‘?‘7‘?‘8‘
????????????‘9‘?‘A‘?‘B‘?‘C‘?‘D‘?‘E‘?‘F‘};
????private?static?final?String?ivHexStr?=?“7380166f?4914b2b9?172442d7?da8a0600?a96f30bc?163138aa?e38dee4d?b0fb0e4e“;
????private?static?final?BigInteger?IV?=?new?BigInteger(ivHexStr.replaceAll(“?“
????????????““)?16);
????private?static?final?Integer?Tj15?=?Integer.valueOf(“79cc4519“?16);
????private?static?final?Integer?Tj63?=?Integer.valueOf(“7a879d8a“?16);
????private?static?final?byte[]?FirstPadding?=?{(byte)?0x80};
????private?static?final?byte[]?ZeroPadding?=?{(byte)?0x00};
????private?static?int?T(int?j)?{
????????if?(j?>=?0?&&?j?<=?15)?{
????????????return?Tj15.intValue();
????????}?else?if?(j?>=?16?&&?j?<=?63)?{
????????????return?Tj63.intValue();
????????}?else?{
????????????throw?new?RuntimeException(“data?invalid“);
????????}
????}
????private?static?Integer?FF(Integer?x?Integer?y?Integer?z?int?j)?{
????????if?(j?>=?0?&&?j?<=?15)?{
????????????return?Integer.valueOf(x.intValue()?^?y.intValue()?^?z.intValue());
????????}?else?if?(j?>=?16?&&?j?<=?63)?{
????????????return?Integer.valueOf((x.intValue()?&?y.intValue())
????????????????????|?(x.intValue()?&?z.intValue())
????????????????????|?(y.intValue()?&?z.intValue()));
????????}?else?{
????????????throw?new?RuntimeException(“data?invalid“);
????????}
????}
????private?static?Integer?GG(Integer?x?Integer?y?Integer?z?int?j)?{
????????if?(j?>=?0?&&?j?<=?15)?{
????????????return?Integer.valueOf(x.intValue()?^?y.intValue()?^?z.intValue());
????????}?else?if?(j?>=?16?&&?j?<=?63)?{
????????????return?Integer.valueOf((x.intValue()?&?y.intValue())
????????????????????|?(~x.intValue()?&?z.intValue()));
????????}?else?{
????????????throw?new?RuntimeException(“data?invalid“);
????????}
????}
????private?static?Integer?P0(Integer?x)?{
????????return?Integer.valueOf(x.intValue()
????????????????^?Integer.rotateLeft(x.intValue()?9)
????????????????^?Integer.rotateLeft(x.intValue()?17));
????}
????private?static?Integer?P1(Integer?x)?{
????????return?Integer.valueOf(x.intValue()
????????????????^?Integer.rotateLeft(x.intValue()?15)
????????????????^?Integer.rotateLeft(x.intValue()?23));
????}
????private?static?byte[]?padding(byte[]?source)?throws?IOException?{
????????if?(source.length?>=?0x2000000000000000l)?{
????????????throw?new?RuntimeException(“src?data?invalid.“);
????????}
????????long?l?=?source.length?*?8;
????????long?k?=?448?-?(l?+?1)?%?512;
????????if?(k?0)?{
????????????k?=?k?+?512;
????????}
????????if?(logger.isDebugEnabled())?{
????????????logger.debug(“k?=?“?+?k);
????????}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-07-03?11:05??sm3\
?????文件????????8217??2014-04-24?14:07??sm3\SM3.java
?????文件???????70453??2015-07-03?11:06??sm3\sm3.png
?????文件??????103677??2015-07-02?10:36??sm3\SM3密碼雜湊算法.pdf
?????文件??????????49??2015-07-03?11:06??sm3\國家SM3算法網址.txt
- 上一篇:java 泡泡堂聯機版
- 下一篇:java swing 鬧鐘源碼
評論
共有 條評論