资源简介

具体使用详见博客 http://blog.csdn.net/hanlin0605/article/details/54809563

资源截图

代码片段和文件信息

package com;

import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.objectInputStream;
import java.io.objectOutputStream;
import java.io.UnsupportedEncodingException;
import java.math.BigInteger;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.RSAPrivateKeySpec;
import java.security.spec.RSAPublicKeySpec;

import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.codec.binary.base64;

import com.google.gson.Gson;

public class RSAAES extends HttpServlet{

private static final long serialVersionUID = -5657272720504177622L;
private static String RSAKeyStore = “C:/RSAKey.txt“;

protected void doGet(HttpServletRequest req HttpServletResponse resp) throws ServletException IOException {
doPost(reqresp);
}

protected void doPost(HttpServletRequest request HttpServletResponse response) throws ServletException IOException {

request.setCharacterEncoding(“UTF-8“); //设定客户端提交给servlet的内容按UTF-8编码
response.setCharacterEncoding(“UTF-8“); //设定servlet传回给客户端的内容按UTF-8编码
response.setContentType(“text/html;charset=UTF-8“); //告知浏览器用UTF-8格式解析内容

String miwen = request.getParameter(“miwen“);
String aKey = request.getParameter(“aKey“);
String aIv = request.getParameter(“aIv“);

//解密RSA加密的AES的key 和 iv
try {
aKey = getString(aKey);
aIv = getString(aIv);
} catch (Exception e) {
e.printStackTrace();
}

//解密由AES加密的密文
        String decrypted = AES_CBC_Decrypt(miwen aKey.getBytes() aIv.getBytes());
        decrypted = URLDecoder.decode(decrypted“UTF-8“);
        System.out.println(“解密后:“+decrypted);        
        
        /**
         * 根据参数 decrypted 模拟连接数据库,查得以下内容
         */
        String yuanCode = “胡歌~!@#¥%……&*()——+=-0987654321·{}:”》?《,。、;’【】、|“
         + “~!@#$%^&*()_LLL“;
        

        //后台AES加密
        yuanCode = URLEncoder.encode(yuanCode“UTF-8“);
String jiami = AES_CBC_Encrypt(yuanCodeaKey.getBytes() aIv.getBytes());
Gson gson = new G

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2017-01-13 16:49  jiami\
     文件        1093  2017-01-13 16:49  jiami\.classpath
     文件        1330  2017-01-13 17:04  jiami\.project
     目录           0  2017-01-13 17:04  jiami\.settings\
     文件         522  2017-01-13 16:49  jiami\.settings\.jsdtscope
     文件         174  2017-01-14 15:36  jiami\.settings\com.genuitec.eclipse.core.prefs
     文件          88  2017-01-13 16:49  jiami\.settings\org.eclipse.core.resources.prefs
     文件         364  2017-01-13 16:49  jiami\.settings\org.eclipse.jdt.core.prefs
     文件         474  2017-01-13 16:49  jiami\.settings\org.eclipse.wst.common.component
     文件         414  2017-01-13 16:49  jiami\.settings\org.eclipse.wst.common.project.facet.core.xml
     文件          49  2017-01-13 16:49  jiami\.settings\org.eclipse.wst.jsdt.ui.superType.container
     文件           6  2017-01-13 16:49  jiami\.settings\org.eclipse.wst.jsdt.ui.superType.name
     目录           0  2017-01-13 16:52  jiami\src\
     目录           0  2017-01-14 16:25  jiami\src\com\
     文件       12037  2017-01-15 17:45  jiami\src\com\RSAAES.java
     目录           0  2017-01-14 14:35  jiami\WebRoot\
     目录           0  2017-01-13 16:53  jiami\WebRoot\components\
     文件        2121  2017-01-14 13:52  jiami\WebRoot\components\aes-min.js
     文件        8080  2017-01-14 13:52  jiami\WebRoot\components\aes.js
     文件        4007  2017-01-14 13:52  jiami\WebRoot\components\cipher-core-min.js
     文件       29182  2017-01-14 13:52  jiami\WebRoot\components\cipher-core.js
     文件        3298  2017-01-14 13:52  jiami\WebRoot\components\core-min.js
     文件       21468  2017-01-14 13:52  jiami\WebRoot\components\core.js
     文件         869  2017-01-14 13:52  jiami\WebRoot\components\enc-base64-min.js
     文件        3338  2017-01-14 13:52  jiami\WebRoot\components\enc-base64.js
     文件         880  2017-01-14 13:52  jiami\WebRoot\components\enc-utf16-min.js
     文件        3747  2017-01-14 13:52  jiami\WebRoot\components\enc-utf16.js
     文件         654  2017-01-14 13:52  jiami\WebRoot\components\evpkdf-min.js
     文件        3698  2017-01-14 13:52  jiami\WebRoot\components\evpkdf.js
     文件         339  2017-01-14 13:52  jiami\WebRoot\components\format-hex-min.js
     文件        1550  2017-01-14 13:52  jiami\WebRoot\components\format-hex.js
............此处省略93个文件信息

评论

共有 条评论