Java¼ÓÃܽâÃÜ
Eryptogram.java Îļþ£º
package com.cube.limail.util;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
/**
* ¼ÓÃܽâÃÜÀà
* @author Ò¶Ê÷Éî
* @version 1.00 2008Äê01ÔÂ03ÈÕ
*/
public class Eryptogram
{
private static String Algorithm ="DES";
private String key="CB7A92E3D3491964";
//¶¨Òå ¼ÓÃÜËã·¨,¿ÉÓà DES,DESede,Blowfish
static boolean debug = false ;
/**
* ¹¹Ôì×Ó×¢½â.
*/
public Eryptogram ()
{
} /**
* Éú³ÉÃÜÔ¿
* @return byte[] ·µ»ØÉú³ÉµÄÃÜÔ¿
* @throws exception ÈÓ³öÒì³£.
*/
public static byte [] getSecretKey () throws Exception
{
KeyGenerator keygen = KeyGenerator.getInstance (Algorithm );
SecretKey deskey = keygen.generateKey ();
System.out.println ("Éú³ÉÃÜÔ¿:"+bytesToHexString (deskey.getEncoded ()));
if (debug ) System.out.println ("Éú³ÉÃÜÔ¿:"+bytesToHexString (deskey.getEncoded ()));
return deskey.getEncoded ();
} /**
* ½«Ö¸¶¨µÄÊý¾Ý¸ù¾ÝÌṩµÄÃÜÔ¿½øÐмÓÃÜ
* @param input ÐèÒª¼ÓÃܵÄÊý¾Ý
* @param key ÃÜÔ¿
* @return byte[]
Ïà¹ØÎĵµ£º
500´íÎó,classnotfoundÒì³££¬´úÂëûÓÐÎÊÌ⣬Êý¾Ý¿âҲûÎÊÌ⣬´òÁ˲¹¶¡£¬×°ÁËÇý¶¯£¬µ«ÊÇÔÚTOMCATÉÏÕÒ²»µ½ÄǸöÇý¶¯¶øÒý·¢µÄ´íÎ󡣡£¡£
½â¾ö°ì·¨£ºÊ×Ñ¡ÏîÉèÖÃÀMyRclipse->J2EE Project->Web Project->Deployment¹´ÉÏÄÇÈý¸öÇý¶¯¡£ ......
²ÎÊý´«µÝ»úÖÆÖ÷ÒªÓÐÁ½ÖÖ£ºÖµµ÷ÓÃ(call-by-value)£¬ÒýÓõ÷ÓÃ(call-by-reference)¡£
Öµµ÷ÓÃ(call-by-value)£º»á¶ÔʵÔÚ²ÎÊýÇóÖµ£¨Èç¹ûÊDZí´ïʽ£©»ò¿½±´£¨Èç¹ûÊDZäÁ¿£©¡£ÕâЩֵ±»·ÅÔÚÊôÓÚ±»µ÷Óùý³ÌµÄÏìÓ¦ÐÎʽ²ÎÊýµÄÄÚ´æλÖÃÉÏ¡£
ÒýÓõ÷ÓÃ(call-by-reference)£ºÊµÔÚ²ÎÊýµÄµØÖ·×÷ΪÏàÓ¦µÄÐÎʽ²ÎÊýµÄÖµ±»´«µÝ¸ø±»µ÷ÓÃÕß¡£ÔÚ±»µ÷ ......
¡¡¡¡Java±à³ÌÖеÄÒì³£´¦ÀíÊÇÒ»¸öºÜ³£¼ûµÄ»°ÌâÁË£¬¼¸ºõÈκÎһÎéÉÜÐÔµÄJava¿Î³Ì¶¼»áÌáµ½Òì³£´¦Àí¡£²»¹ý£¬ÎÒÈÏΪºÜ¶àÈËÆäʵ²¢Ã»ÓÐÕæÕýÕÆÎÕÕýÈ·´¦ÀíÒì³£Çé¿öµÄ·½·¨ºÍ²ßÂÔ£¬×î¶àÒ²¾Í²»¹ýÁ˽â¸ö´ó¸Å£¬ÖªµÀµã¸ÅÄî¡£±¾ÎľͶÔÈýÖÖ²»Í¬³Ì¶ÈºÍÖÊÁ¿µÄJavaÒì³£´¦Àí½øÐÐÁËÌÖÂÛ£¬Ëù²ûÊöµÄ´¦ÀíÒì³£µÄ·½Ê½°´ÊÖ·¨µÄ¸ßÏ·ÖΪ£ººÃ£¬²»ºÃºÍ¶ñÁÓ ......
java ÐÞÊηûºÍ·ÃÎÊȨÏÞ½éÉÜ
ÐÞÊηû½éÉÜ£º
public
ʹÓöÔÏó:Àà¡¢½Ó¿Ú¡¢³ÉÔ±±äÁ¿¡¢·½·¨
½éÉÜ:ÎÞÂÛËüËù´¦ÔÚ°ü¶¨ÒåÔÚÄĸÃÀà(½Ó¿Ú¡¢³ÉÔ±)¶¼ÊÇ¿É·ÃÎÊ
protected
ʹÓöÔÏó:³ÉÔ±±äÁ¿¡¢·½·¨
½éÉÜ:³ÉÔ±±äÁ¿Ö»ÄÜÔÚ¶¨ÒåËü°üÖб»·ÃÎÊ£¬Èç¹ûÔÚÆäËû°üÖб»·ÃÎÊ£¬ÔòʵÏÖÕâ¸ö˼··½·¨Àà±ØÐëÊǸóÉÔ±ËùÊôÀà×ÓÀà
private
ʹÓöÔÏó:³É ......
Ò»£® InputºÍOutput
1. stream´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputºÍOut stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
1.1 ÒÔ×Ö½ÚΪµ¼ÏòµÄstream
ÒÔ×Ö½ÚΪµ¼ÏòµÄstream£¬±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈëÐÅÏ¢¡£ÒÔ×Ö½ÚΪµ¼ÏòµÄstream°üÀ¨ÏÂÃæ¼¸Ö ......