- 博客(1)
- 资源 (14)
- 收藏
- 关注
转载 HTTP头部详解及使用Java套接字处理HTTP请求
进行Web开发关键是要了解超文本传输协议(HTTP),该协议用来传输网页图像以及因特网上在浏览器与服务器间传输的其他类型文件只要你在浏览器上输入一个URL,最前面的http://就表示使用HTTP来访问指定位置的信息(大部分浏览器还支持其他一些不同的协议,其中FTP就是一个典型例子)本文从HTTP协议的结构上初步探讨HTTP协议的工作原理和请求响应格式,并最后通过一个使用Java编写的小
2008-08-25 17:24:00
968
AES加密解密JAVA实现(带源码)
import javax.crypto.*;import javax.crypto.spec.*;public class AES { public static void main(String[] args) throws Exception { /* 加密用的Key 可以用26个字母和数字组成,最好不要用保留字符,虽然不会错,至于怎么裁决,个人看情况而定 */ String cKey = "1234567890abcDEF"; //需要加密的字串 String cSrc = "Email : xxx@xxx.com" ; //加密 long lStart = System.currentTimeMillis(); String enString = AES.Encrypt(cSrc, cKey); System.out.println("加密后的字串是:" + enString); long lUseTime = System.currentTimeMillis() - lStart; System.out.println("加密耗时:" + lUseTime + "毫秒")
2008-06-30
AES加解密JAVA实现(源码)
最近写一些加密解密的代码,找了不少的文章,结合自己的理解,现把我写的代码POST出来,供大家参考。import javax.crypto.*;import javax.crypto.spec.*;public class AES { public static void main(String[] args) throws Exception { /* 加密用的Key 可以用26个字母和数字组成,最好不要用保留字符,虽然不会错,至于怎么裁决,个人看情况而定 */ String cKey = "1234567890abcDEF"; //需要加密的字串 String cSrc = "我的MSN:xxxx@hotmail.com,QQ:10000" ; //加密 long lStart = System.currentTimeMillis(); String enString = AES.Encrypt(cSrc, cKey); System.out.println("加密后的字串是:" + enString); long lUseTime = System.currentTimeMillis() - lStart; System.out.println("加密耗时:" + lUseTime + "毫秒"); //解密 lStart = System.currentTimeMillis(); String DeString = AES.Decrypt(enString, cKey); System.out.println("解密后的字串是:" + DeString); lUseTime = System.currentTimeMillis() - lStart; System.out.println("解密耗时:" + lUseTime + "毫秒"); } public static String Decrypt(String sSrc, String sKey) throws Exception { try { //判断Key是否正确 if (sKey == null) { System.out.print("Key为空null"); return null; } //判断Key是否为16位 if (sKey.length() != 16) { System.out.print("Key长度不是16位"); return null; } byte[] raw = sKey.getBytes("ASCII"); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.DECRYPT_MODE, skeySpec); byte[] encrypted1 = hex2byte(sSrc); try { byte[] original = cipher.doFinal(encrypted1); String originalString = new String(original); return originalString; } catch (Exception e) { System.out.println(e.toString()); return null; } } catch (Exception ex) { System.out.println(ex.toString()); return null; } } //判断Key是否正确 public static String Encrypt(String sSrc, String sKey) throws Exception { if (sKey == null) { System.out.print("Key为空null"); return null; } //判断Key是否为16位 if (sKey.length() != 16) { System.out.print("Key长度不是16位"); return null; } byte[] raw = sKey.getBytes("ASCII"); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); Cipher cipher = Cipher.getInstance("AES"); cipher.init(Cipher.ENCRYPT_MODE, skeySpec); byte[] encrypted = cipher.doFinal(sSrc.getBytes()); return byte2hex(encrypted).toLowerCase(); } public static byte[] hex2byte(String strhex) { if (strhex == null) { return null; } int l = strhex.length(); if (l % 2 == 1) { return null; } byte[] b = new byte[l / 2]; for (int i = 0; i != l / 2; i++) { b[i] = (byte) Integer.parseInt(strhex.substring(i * 2, i * 2 + 2), 16); } return b; } public static String byte2hex(byte[] b) { String hs = ""; String stmp = ""; for (int n = 0; n < b.length; n++) { stmp = (java.lang.Integer.toHexString(b[n] & 0XFF)); if (stmp.length() == 1) { hs = hs + "0" + stmp; } else { hs = hs + stmp; } } return hs.toUpperCase(); }}以上代码执行结果加密后的字串是:e965a929ae598b701bc2bc4714164c27524aab4769f269c434c55b61e398600175a38e0a4794cdef9c0463a182d2cde3加密耗时:672毫秒解密后的字串是:我的MSN:xxxx@hotmail.com,QQ:10000解密耗时:0毫秒
2008-06-30
ext Panel+toolbar+button 实作带注释
ext Panel+toolbar+button 实作带注释<br>Tom 实作实例,推荐入门学习,不带Ext js lib,请自行加入
2008-06-26
JQuery入门指南(中文)+实例
这个指南是一个对jQuery库的说明,要求读者了解HTML(DOM)和CSS的一些常识。它包括了一个简单的Hello World的例子,选择器和事件基础,AJAX、FX的用法,以及如何制作jQuery的插件。 这个指南包括了很多代码,你可以copy它们,并试着修改它们,看看产生的效果。
2008-06-25
JQuery 1.2.5 (最新版)
jQuery是JavaScript语言的一个新的资源库(框架) <br><br>jQuery能快速,简洁的使用HTML documents, handle events, perform animations,并且能把Ajax交互应用到网页,jQuery能够改变你书写JavaScript的方式.
2008-06-01
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人