15 Star 34 Fork 11

未命名 / org.yq.tools.encrypt

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
WTFPL

#java_jiami

java加密解密算法工具包。其中包括MD5,SHA1,AES,DES,RSA等对称或对称加密算法

1.RSA使用方法

1.1 生成公私钥

	static String publicKey;
	static String privateKey;

	/**
	 * 生成公私钥
	 */
	@Before
	public void init() {
		try {
			Map<String, Object> keyMap = RSAUtil.genKeyPair();
			publicKey = RSAUtil.getPublicKey(keyMap);
			privateKey = RSAUtil.getPrivateKey(keyMap);
			System.out.println("公钥: \n\r" + publicKey);
			System.out.println("私钥: \n\r" + privateKey);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

1.2 RSA对文件进行加解密

		try {
			String dir = RSATest.class.getResource("/").getFile();
			File sourceFile = new File(dir+File.separator+"test.txt");
			System.out.println(sourceFile.getAbsolutePath());
			File targetFile = new File(dir+File.separator+"test_rsa.txt");
			//加密
			RSAUtil.encryptByPrivateKey2File(sourceFile, targetFile, privateKey);
			String sign = RSAUtil.sign(targetFile, privateKey);
			
			//签名检查
			boolean status = RSAUtil.verify(targetFile, publicKey, sign);
			assertTrue(status);
			
			//解密
			File targetFile2 = new File(dir+File.separator+"test_rsa_de.txt");
			RSAUtil.decryptByPublicKey2File(targetFile, targetFile2, publicKey);
			
		} catch (Exception e) {
			e.printStackTrace();
			throw new EncryptException();
		}

2.AES使用方法

2.1 待补充

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE Version 2, December 2004 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net> Everyone is permitted to copy and distribute verbatim or modified copies of this license document, and changing it is allowed as long as the name is changed. DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. You just DO WHAT THE FUCK YOU WANT TO.

简介

java加密解密算法工具包。其中包括MD5,SHA1,AES,DES,RSA等对称或对称加密算法 展开 收起
Java
WTFPL
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/yuquan0405/org.yq.tools.encrypt.git
git@gitee.com:yuquan0405/org.yq.tools.encrypt.git
yuquan0405
org.yq.tools.encrypt
org.yq.tools.encrypt
master

搜索帮助

53164aa7 5694891 3bd8fe86 5694891