SM4 (课下作业,选做)

参考 http://gmssl.org/docs/java-api.html ,用SM4算法对你的学号,姓名进行加密,提交代码和密文截图
1 基于命令行的方式使用sm4对你的八位学号中的前六位班级进行加密
2 基于命令行的方式使用sm4对你的姓名进行加密
3 基于命令行的方式使用sm3对你的八位学号中的前六位班级求摘要值
4 基于命令行的方式使用sm3对你的姓名进行求摘要值
5 提交1234步的截图

代码如下

public class GmSSL {

	public native String getVersion(int type);
	public native byte [] generateRandom(int length);
	public native String [] getCiphers(boolean aliases);
	public native int getCipherIVLength(String cipher);
	public native int getCipherKeyLength(String cipher);
	public native int getCipherBlockSize(String cipher);
	public native byte [] symmetricEncrypt(String cipher, int flag, byte [] in, byte [] key, byte [] iv);
	public native byte [] symmetricDecrypt(String cipher, int flag, byte [] in, byte [] key, byte [] iv);
	public native String [] getDigests(boolean aliases);
	public native int getDigestLength(String digestAlgor);
	public native int getDigestBlockSize(String digestAlgor);
	public native byte [] digest(String algor, int flag, byte [] data);
	public native String [] getMacs(boolean aliases);
	public native String [] getMacLength(String algor);
	public native byte [] mac(String algor, int flag, byte [] data, byte [] key);
	public native String [] getSignAlgorithms(boolean aliases);
	public native byte [] sign(String algor, int flag, byte [] data, byte [] privateKey);
	public native int verify(String algor, int flag, byte [] digest, byte [] signature, byte [] publicKey);
	public native String [] getPublicKeyEncryptions(boolean aliases);
	public native byte [] publicKeyEncrypt(String algor, int flag, byte [] in, byte [] publicKey);
	public native byte [] publicKeyDecrypt(String algor, int falg, byte [] in, byte [] privateKey);
	public native String [] getDeriveKeyAlgorithms(boolean aliases);
	public native byte [] deriveKey(String algor, int flag, int keyLength, byte [] peerPublicKey, byte [] privateKey);
	public native String getErrorString();

	static {
		System.loadLibrary("gmssl");
	}
}




码云链接

https://gitee.com/yukungbhy/yukun-20155335/commit/05a40bd9ac4b1b5f64409c4bfc984a3919bfd25e

posted on 2019-06-03 15:06  俞昆  阅读(244)  评论(0)    收藏  举报

导航