Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 Excel API ʹÓ÷½·¨


    ʹÓÃWindows²Ù×÷ϵͳµÄÅóÓѶÔExcel£¨µç×Ó±í¸ñ£©Ò»¶¨²»»áÄ°Éú£¬µ«ÊÇҪʹÓÃJavaÓïÑÔÀ´²Ù×ÝExcelÎļþ²¢²»ÊÇÒ»¼þÈÝÒ×µÄÊ¡£ÔÚWebÓ¦ÓÃÈÕÒæÊ¢ÐеĽñÌ죬ͨ¹ýWebÀ´²Ù×÷ExcelÎļþµÄÐèÇóÔ½À´Ô½Ç¿ÁÒ£¬Ä¿Ç°½ÏΪÁ÷ÐеIJÙ×÷ÊÇÔÚJSP»òServlet Öд´½¨Ò»¸öCSV £¨comma separated values£©Îļþ£¬²¢½«Õâ¸öÎļþÒÔMIME£¬te ......

ͨ¹ýjava·´Éä»úÖƶ¯Ì¬µ÷ÓÃij·½·¨µÄ×ܽá

ͨ¹ýjavaµÄ·´Éä»úÖÆ£¬¶¯Ì¬µ÷ÓÃij¸ö·½·¨£º
ÈçÏ£º
public Object invokeMethod(String className, String methodName,
Object[] args) throws Exception{
Class ownerClass = Class.forName(className);
Object owner = ownerClass.newInstance();

Class[] argsClass = new Class[args.length ......

ÓÃjava¶ÁÎļþÄÚÈÝ

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.RandomAccessFile;
import java.io.Reader;
/**
 *
 * ¶àÖÖ·½Ê½¶ÁÎ ......

JAVA½«ÄÚÈÝ×·¼Óµ½Îļþβ²¿

import java.io.FileWriter;
import java.io.IOException;
import java.io.RandomAccessFile;
/**
 * ½«ÄÚÈÝ×·¼Óµ½Îļþβ²¿
 */
public class AppendToFile
{
    /**
     * A·½·¨×·¼ÓÎļþ£ºÊ¹ÓÃRandomAccessFile
     *
    ......

javaÐÔÄܵÄÓÅ»¯(¶þ)

    Èý£®ÓÅ»¯JAVA³ÌÐòÉè¼ÆºÍ±àÂ룬Ìá¸ßJAVA³ÌÐòÐÔÄܵÄһЩ·½·¨¡£
   
ͨ¹ýʹÓÃһЩǰÃæ½éÉܹýµÄ¸¨ÖúÐÔ¹¤¾ßÀ´ÕÒµ½³ÌÐòÖеÄÆ¿¾±£¬È»ºó¾Í¿ÉÒÔ¶ÔÆ¿¾±²¿·ÖµÄ´úÂë½øÐÐÓÅ»¯¡£Ò»°ãÓÐÁ½ÖÖ·½°¸£º¼´ÓÅ»¯´úÂë»ò¸ü¸ÄÉè¼Æ·½·¨¡£ÎÒÃÇÒ»°ã»áÑ¡
ÔñºóÕߣ¬ÒòΪ²»È¥µ÷ÓÃÒÔÏ´úÂëÒª±Èµ÷ÓÃһЩÓÅ»¯µÄ´úÂë¸üÄÜÌá ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ