資源簡介
《Java設計模式》源代碼.rar
“結(jié)構(gòu)型模式”中的“適配器模式”的定義、結(jié)構(gòu)與使用。
“結(jié)構(gòu)型模式”中的“橋接模式”的定義、結(jié)構(gòu)與使用。
“結(jié)構(gòu)型模式”中的組合模式的定義、結(jié)構(gòu)與使用。
“結(jié)構(gòu)型模式”中的裝飾模式的定義、結(jié)構(gòu)與使用。
“結(jié)構(gòu)型模式”中的外觀模式的定義、結(jié)構(gòu)與使用。
“結(jié)構(gòu)型模式”中的享元模式的定義、結(jié)構(gòu)與使用。
“結(jié)構(gòu)型模式”中的代理模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的職責鏈模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的命令模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的解釋器模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的迭代器模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的中介者模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的備忘錄模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的觀察者模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的狀態(tài)模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的策略模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的模板方法模式的定義、結(jié)構(gòu)與使用。
“行為型模式”中的訪問者模式的定義、結(jié)構(gòu)與使用。
代碼片段和文件信息
import?javax.crypto.Cipher;
import?javax.crypto.KeyGenerator;
import?javax.crypto.SecretKey;
public?class?DESEncrypt?{
public?static?void?main(String?args[])
{
String?codeStringBegin=“Sunny?Liu“;??//要加密的明文
String?codeStringEnd=null;?????????????//加密后的密文
String?decodeString=null;??????????????//密文解密后得到的明文
String?cipherType?=?“DESede“;?//加密算法類型,可設置為DES、DESede、AES等字符串
try
{
//獲取密鑰生成器
KeyGenerator?keyGen=KeyGenerator.getInstance(cipherType);
//初始化密鑰生成器,不同的加密算法其密鑰長度可能不同
keyGen.init(112);
//生成密鑰
SecretKey?key=keyGen.generateKey();
//得到密鑰字節(jié)碼
byte[]?keyByte=key.getEncoded();
//輸出密鑰的字節(jié)碼
System.out.println(“密鑰是:“);
for(int?i=0;i {
System.out.print(keyByte[i]+““);
}
System.out.println(““);
//創(chuàng)建密碼器
Cipher?cp=Cipher.getInstance(cipherType);?
//初始化密碼器
cp.init(Cipher.ENCRYPT_MODEkey);
System.out.println(“要加密的字符串是:“+?codeStringBegin);
byte[]?codeStringByte=codeStringBegin.getBytes(“UTF8“);
System.out.println(“要加密的字符串對應的字節(jié)碼是:“);
for(int?i=0;i {
System.out.print(codeStringByte[i]+““);
}
System.out.println(““);
//開始加密
byte[]?codeStringByteEnd=cp.doFinal(codeStringByte);
System.out.println(“加密后的字符串對應的字節(jié)碼是:“);
for(int?i=0;i {
System.out.print(codeStringByteEnd[i]+““);
}
System.out.println(““);
codeStringEnd=new?String(codeStringByteEnd);
System.out.println(“加密后的字符串是:“?+?codeStringEnd);
System.out.println(““);
//重新初始化密碼器
cp.init(Cipher.DECRYPT_MODEkey);
//開始解密
byte[]?decodeStringByteEnd=cp.doFinal(codeStringByteEnd);
System.out.println(“解密后的字符串對應的字節(jié)碼是:“);
for(int?i=0;i {
System.out.print(decodeStringByteEnd[i]+““);
}
System.out.println(““);
decodeString=new?String(decodeStringByteEnd);
System.out.println(“解密后的字符串是:“?+?decodeString);
System.out.println(““);
}?
catch(Exception?e)
{
e.printStackTrace();
}
}???
}
?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????????0??2012-02-11?08:46??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件???????1991??2012-02-11?13:06??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件???????2805??2012-02-11?13:06??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件???????1991??2012-02-11?13:06??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????????1??2012-02-12?10:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????151??2012-02-12?10:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????????1??2012-02-12?10:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件???????2063??2012-02-12?10:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????772??2012-02-12?10:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件?????????73??2012-02-11?08:51??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????478??2012-02-11?13:06??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????188??2012-02-11?08:50??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????479??2012-02-11?13:06??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????554??2012-02-11?13:04??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????100??2012-02-11?08:57??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????160??2012-02-11?13:06??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件?????????79??2012-02-11?08:46??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????544??2012-02-11?08:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????544??2012-02-11?08:50??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????????552??2012-02-11?08:55??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件???????1795??2012-02-12?10:53??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????92660??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件?????147925??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件???????1566??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????16046??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????35792??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件?????????25??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件????9641828??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????21328??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
?????文件??????45471??2012-02-11?13:05??《Java設計模式》源代碼(程細柱)\Chapter?04?Simple?Factory\.me
............此處省略2480個文件信息
評論
共有 條評論