资源简介
Java 生成RSA密钥进行数据加密解密 支持超长字符分区 ,同时支持本地读取生成的密钥文件和远程服务器上存放的秘钥文件

代码片段和文件信息
/*
* Java base64 - A pure Java library for reading and writing base64
* encoded streams.
*
* Copyright (C) 2007-2009 Carlo Pelliccia (www.sauronsoftware.it)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version
* 2.1 as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License version 2.1 along with this program.
* If not see .
*/
package com.soft.common.shared.security.utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
/**
*
* base64 encoding and decoding utility methods both for binary and textual
* informations.
*
*
* @author Carlo Pelliccia
* @since 1.1
* @version 1.3
*/
public class base64 {
/**
*
* Encodes a string.
*
*
* Before the string is encoded in base64 it is converted in a binary
* sequence using the system default charset.
*
*
* @param str
* The source string.
* @return The encoded string.
* @throws RuntimeException
* If an unexpected error occurs.
*/
public static String encode(String str) throws RuntimeException {
byte[] bytes = str.getBytes();
byte[] encoded = encode(bytes);
try {
return new String(encoded “ASCII“);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(“ASCII is not supported!“ e);
}
}
/**
*
* Encodes a string.
*
*
* Before the string is encoded in base64 it is converted in a binary
* sequence using the supplied charset.
*
*
* @param str
* The source string
* @param charset
* The charset name.
* @return The encoded string.
* @throws RuntimeException
* If an unexpected error occurs.
* @since 1.2
*/
public static String encode(String str String charset)
throws RuntimeException {
byte[] bytes;
try {
bytes = str.getBytes(charset);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(“Unsupported charset: “ + charset e);
}
byte[] encoded = encode(bytes);
try {
return new String(encoded “ASCII“);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(“ASCII is not supported!“ e);
}
}
/**
*
* Decodes the supplied string.
*
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-08-25 16:07 TestJavaRSA\
文件 301 2017-08-17 10:11 TestJavaRSA\.classpath
文件 387 2017-08-17 10:11 TestJavaRSA\.project
目录 0 2017-08-25 16:07 TestJavaRSA\.settings\
文件 629 2017-08-17 10:11 TestJavaRSA\.settings\org.eclipse.jdt.core.prefs
目录 0 2017-08-25 16:07 TestJavaRSA\bin\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\dpap\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\dpap\common\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\dpap\common\shared\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\
文件 5690 2017-08-22 09:49 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\ba
文件 1904 2017-08-22 09:49 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\ba
文件 1802 2017-08-22 09:49 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\ba
文件 2660 2017-08-22 09:49 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\ba
文件 1421 2017-08-24 16:48 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\ReadFromFile.class
文件 6813 2017-08-22 09:49 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\RSAUtils.class
文件 554 2017-08-22 09:49 TestJavaRSA\bin\com\deppon\dpap\common\shared\security\utils\Shared.class
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\javaRsa\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\deppon\javaRsa\test\
文件 3291 2017-08-25 15:13 TestJavaRSA\bin\com\deppon\javaRsa\test\TestRsa.class
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\soft\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\soft\common\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\soft\common\shared\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\soft\common\shared\security\
目录 0 2017-08-25 16:07 TestJavaRSA\bin\com\soft\common\shared\security\utils\
文件 5655 2017-08-25 15:54 TestJavaRSA\bin\com\soft\common\shared\security\utils\ba
文件 1883 2017-08-25 15:54 TestJavaRSA\bin\com\soft\common\shared\security\utils\ba
文件 1781 2017-08-25 15:54 TestJavaRSA\bin\com\soft\common\shared\security\utils\ba
............此处省略24个文件信息
- 上一篇:基于JSP的网上书店管理系统论文
- 下一篇:数据库课程设计(银行账户管理系统
相关资源
- Windows bat 设置Java环境变量
- java 毕业设计 进销存管理系统 源码
- java图片浏览器跨平台运行程序与源码
- 基于java的在线考试系统-毕业设计
- 微博系统(Java源码,servlet+jsp),适
- java串口通信全套完整代码-导入eclip
- jsonarray所必需的6个jar包.rar
- 三角网构TIN生成算法,Java语言实现
- java代码编写将excel数据导入到mysql数据
- Java写的cmm词法分析器源代码及javacc学
- JAVA JSP公司财务管理系统 源代码 论文
- JSP+MYSQL旅行社管理信息系统
- 推荐算法的JAVA实现
- 基于Java的酒店管理系统源码(毕业设
- java-图片识别 图片比较
- android毕业设计
- java23种设计模式+23个实例demo
- java Socket发送/接受报文
- JAVA828436
- java界面美化 提供多套皮肤直接使用
- 在线聊天系统(java代码)
- 基于Java的图书管理系统807185
- java中实现将页面数据导入Excel中
- java 企业销售管理系统
- java做的聊天系统(包括正规课程设计
- Java编写的qq聊天室
- 商店商品管理系统 JAVA写的 有界面
- JAVA开发聊天室程序
- 在linux系统下用java执行系统命令实例
- java期末考试试题两套(答案) 选择(
评论
共有 条评论