易截截图软件、单文件、免安装、纯绿色、仅160KB

java php DES 加密解密

import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte[] desKey;
public DES(String desKey) {
this.desKey = desKey.getBytes();
}
public byte[] desEncrypt(byte[] plainText) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = desKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key, sr);
byte data[] = plainText;
byte encryptedData[] = cipher.doFinal(data);
return encryptedData;
}
public byte[] desDecrypt(byte[] encryptText) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = desKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.DECRYPT_MODE, key, sr);
byte encryptedData[] = encryptText;
byte decryptedData[] = cipher.doFinal(encryptedData);
return decryptedData;
}
public String encrypt(String input) throws Exception {
return base64Encode(desEncrypt(input.getBytes()));
}
public String decrypt(String input) throws Exception {
byte[] result = base64Decode(input);
return new String(desDecrypt(result));
}
public static String base64Encode(byte[] s) {
if (s == null)
return null;
BASE64Encoder b = new sun.misc.BASE64Encoder();
return b.encode(s);
}
public static byte[] base64Decode(String s) throws IOException {
if (s == null)
return null;
BASE64Decoder decoder = new BASE64Decoder();
byte[] b = decoder.de


相关文档:

java rmi简单例子

----------接口------------
import java.rmi.*;
public interface HelloIn extends java.rmi.Remote{
 String sayHello() throws RemoteException;
}
--------实现类-------------
import java.rmi.*;
import java.net.*;
import java.rmi.registry.*;
import java.rmi.server.*;
public class Hello exten ......

Java中字符串与ASCII相互转换


import java.io.UnsupportedEncodingException;
public class T {
 public static void main(String[] args) throws UnsupportedEncodingException {
  t1();//ASCII转换为字符串
  t2();//字符串转换为ASCII码
 }
 public static void t1(){//ASCII转换为字符串
   ......

C#, Java 和 Matlab 6.5 书籍

ed2k://|file|[ReadFree]_C#.开发人员指南——ASP_NET、XML、web服务与.ADO_NET_11030729.rar|6563070|B1CBF4D0032C8D78FB10F5F2AE6C3882|/
ed2k://|file|[ReadFree]_C#网络应用编程_11041620.rar|8063056|7044A65903D86BF88BE8AF26D8E02B61|/
ed2k://|file|[ReadFree]_Java.P2P程序设计_11052086.rar|8742852| ......

Java调用SQL Server的存储过程详解

1使用不带参数的存储过程
  使用 JDBC 驱动程序调用不带参数的存储过程时,必须使用 call SQL 转义序列。不带参数的 call 转义序列的语法如下所示:
  
以下是引用片段:
{call procedure-name}
  作为实例,在 SQL Server 2005 AdventureWorks 示例数据库中创建以下存储过程:
  
以下是引用片段: ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号