资源简介
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的网上书店管理系统论文
- 下一篇:数据库课程设计(银行账户管理系统
相关资源
-
xm
lschema-core-2.2.1.jar - java,二维码生成算法
- java简易五子棋源代码+图片素材图形界
- java画板程序支持文件打开,保存。
- 飞机大战(java项目)
- java二维数组输出下三角矩阵
- 用java写的一个图书管理系统
- JAVA实现摄像头的录像功能
- java培训课件
- mysql-connector-java-5.1.36-bin
- 骆昊JAVA面试题全集2018博客文章整理
- SGIP 彩信 java SP 接口
- java 大富翁源码、详细注释
- java300集2018.txt
- 基于java socket的简单FTP功能实现
- Java实现符号三角形问题的算法
- Java实现图的m着色问题算法
- Java串口开发用到的comm.jar,javax.comm
- 多种设计模式综合练习
- DoubleCA版本的国密算法JCE(Java Crypto
- Main.java
- 使用java多线程实现mm跳舞动画
- java实现swing的网络通信私聊,公聊,
- javaee加密部署
- Java读取Excel表格数据时.xls、.xlsx 格式
- Java编写的简易文本编辑器
- java实现维诺图
- java源码小区物业管理系统
- fckeditor-java-core-2.4.1.jar
- 2016年最新java面试题及答案使用于初级
评论
共有 条评论