锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精品乱码一区二区 ,国产亚洲漂亮白嫩美女在线,亚洲最大在线视频http://www.tkk7.com/wuxufeng8080/category/12855.htmlzh-cnFri, 02 Mar 2007 02:04:42 GMTFri, 02 Mar 2007 02:04:42 GMT60Java鍔犲瘑鍜屾暟瀛楃鍚?/title><link>http://www.tkk7.com/wuxufeng8080/articles/78466.html</link><dc:creator>椋庝漢鍥?/dc:creator><author>椋庝漢鍥?/author><pubDate>Wed, 01 Nov 2006 06:07:00 GMT</pubDate><guid>http://www.tkk7.com/wuxufeng8080/articles/78466.html</guid><description><![CDATA[ <a> <span id="cwmumum" class="f14">鏈枃涓昏璋堜竴涓嬪瘑鐮佸涓殑鍔犲瘑鍜屾暟瀛楃鍚嶏紝浠ュ強鍏跺湪java涓浣曡繘琛屼嬌鐢ㄣ傚瀵嗙爜瀛︽湁鍏磋叮鐨勪紮浼達紝鎺ㄨ崘鐪?Bruce Schneier鐨勮憲浣滐細Applied Crypotography銆傚湪jdk1.5鐨勫彂琛岀増鏈腑瀹夊叏鎬ф柟闈㈡湁浜嗗緢澶х殑鏀硅繘錛屼篃鎻愪緵浜嗗RSA綆楁硶鐨勭洿鎺ユ敮鎸侊紝鐜板湪鎴戜滑浠庡疄渚嬪叆鎵嬭В鍐抽棶棰橈紙鏈枃浠呮槸浣滀負綆鍗曚粙緇嶏級錛?<br /><br />銆銆<strong>涓銆佸瘑鐮佸涓婂父鐢ㄧ殑姒傚康</strong>銆<br /><br />銆銆1錛夋秷鎭憳瑕侊細<br /><br />銆銆榪欐槸涓縐嶄笌娑堟伅璁よ瘉鐮佺粨鍚堜嬌鐢ㄤ互紜繚娑堟伅瀹屾暣鎬х殑鎶鏈備富瑕佷嬌鐢ㄥ崟鍚戞暎鍒楀嚱鏁扮畻娉曪紝鍙敤浜庢楠屾秷鎭殑瀹屾暣鎬э紝鍜岄氳繃鏁e垪瀵嗙爜鐩存帴浠ユ枃鏈艦寮忎繚瀛樼瓑錛岀洰鍓嶅箍娉涗嬌鐢ㄧ殑綆楁硶鏈塎D4銆丮D5銆丼HA-1錛宩dk1.5瀵逛笂闈㈤兘鎻愪緵浜嗘敮鎸侊紝鍦╦ava涓繘琛屾秷鎭憳瑕佸緢綆鍗曪紝 java.security.MessageDigest鎻愪緵浜嗕竴涓畝鏄撶殑鎿嶄綔鏂規硶錛?br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />*MessageDigestExample.java<br />*Copyright聽2005-2-16<br /></span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽java.security.MessageDigest;<br /></span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />*鍗曚竴鐨勬秷鎭憳瑕佺畻娉曪紝涓嶄嬌鐢ㄥ瘑鐮?鍙互鐢ㄦ潵瀵規槑鏂囨秷鎭紙濡傦細瀵嗙爜錛夐殣钘忎繚瀛?br /></span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)">聽MessageDigestExample{<br />銆</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)">聽main(String[]聽args)聽</span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)">聽Exception{<br />銆銆</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">(args.length</span><span style="COLOR: rgb(0,0,0)">!=</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">){<br />銆銆銆System.err.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Usage:java聽MessageDigestExample聽text</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆銆System.exit(</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆}<br /><br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽plainText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">args[</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">].getBytes(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /><br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">浣跨敤getInstance("綆楁硶")鏉ヨ幏寰楁秷鎭憳瑕?榪欓噷浣跨敤SHA-1鐨?60浣嶇畻娉?/span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆MessageDigest聽messageDigest</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">MessageDigest.getInstance(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">SHA-1</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /><br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\n</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">messageDigest.getProvider().getInfo());<br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">寮濮嬩嬌鐢ㄧ畻娉?/span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆messageDigest.update(plainText);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nDigest:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">杈撳嚭綆楁硶榪愮畻緇撴灉</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆System.out.println(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽String(messageDigest.digest(),</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br />銆}<br />}</span></div><br />銆銆榪樺彲浠ラ氳繃娑堟伅璁よ瘉鐮佹潵榪涜鍔犲瘑瀹炵幇錛宩avax.crypto.Mac鎻愪緵浜嗕竴涓В鍐蟲柟妗堬紝鏈夊叴瓚h呭彲浠ュ弬鑰冪浉鍏矨PI鏂囨。錛屾湰鏂囧彧鏄畝鍗曚粙緇嶄粈涔堟槸鎽樿綆楁硶銆?br /><br />榪欓噷琛ュ厖鍙︿竴涓繍鐢ㄦ秷鎭憳瑕佺殑鏂瑰紡鍔犲瘑鐨勪緥瀛?<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)">聽TestEncrypt聽{<br /><br />聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽TestEncrypt()聽{<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />聽聽聽聽聽*聽</span><span style="COLOR: rgb(128,128,128)">@param</span><span style="COLOR: rgb(0,128,0)">聽strSrc聽聽:strSrc聽is聽a聽string聽will聽be聽encrypted,<br />聽聽聽聽聽*聽</span><span style="COLOR: rgb(128,128,128)">@param</span><span style="COLOR: rgb(0,128,0)">聽encName聽:聽encName聽is聽the聽algorithm聽name聽will聽be聽used.<br />聽聽聽聽聽*聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽encName聽dafault聽to聽"MD5"<br />聽聽聽聽聽*聽</span><span style="COLOR: rgb(128,128,128)">@return</span><span style="COLOR: rgb(0,128,0)">聽String<br />聽聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br />聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽String聽Encrypt(String聽strSrc,聽String聽encName)聽{<br /><br />聽聽聽聽聽聽聽聽MessageDigest聽md聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽String聽strDes聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">;<br /><br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽bt聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽strSrc.getBytes();<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">try</span><span style="COLOR: rgb(0,0,0)">聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">聽(encName聽</span><span style="COLOR: rgb(0,0,0)">==</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">||</span><span style="COLOR: rgb(0,0,0)">聽encName.equals(</span><span style="COLOR: rgb(0,0,0)">""</span><span style="COLOR: rgb(0,0,0)">))聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽encName聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">MD5</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽md聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽MessageDigest.getInstance(encName);<br />聽聽聽聽聽聽聽聽聽聽聽聽md.update(bt);<br />聽聽聽聽聽聽聽聽聽聽聽聽strDes聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽bytes2Hex(md.digest());聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">to聽HexString</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">catch</span><span style="COLOR: rgb(0,0,0)">聽(NoSuchAlgorithmException聽e)聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Invalid聽algorithm.</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)">聽strDes;<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽String聽bytes2Hex(</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽bts)聽{<br />聽聽聽聽聽聽聽聽String聽des聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">""</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽String聽tmp聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">for</span><span style="COLOR: rgb(0,0,0)">聽(</span><span style="COLOR: rgb(0,0,255)">int</span><span style="COLOR: rgb(0,0,0)">聽i聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">;聽i聽</span><span style="COLOR: rgb(0,0,0)"><</span><span style="COLOR: rgb(0,0,0)">聽bts.length;聽i</span><span style="COLOR: rgb(0,0,0)">++</span><span style="COLOR: rgb(0,0,0)">)聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽tmp聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽(Integer.toHexString(bts[i]聽</span><span style="COLOR: rgb(0,0,0)">&</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">0xFF</span><span style="COLOR: rgb(0,0,0)">));<br />聽聽聽聽聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">聽(tmp.length()聽</span><span style="COLOR: rgb(0,0,0)">==</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">)聽{<br />聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽des聽</span><span style="COLOR: rgb(0,0,0)">+=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽聽聽聽聽des聽</span><span style="COLOR: rgb(0,0,0)">+=</span><span style="COLOR: rgb(0,0,0)">聽tmp;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)">聽des;<br />聽聽聽聽}<br /><br />聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)">聽main(String[]args)聽{<br />聽聽聽聽聽聽聽聽TestEncrypt聽te聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽TestEncrypt();<br />聽聽聽聽聽聽聽聽String聽strSrc聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">鍙互鍔犲瘑姹夊瓧.Oh,and聽english</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Source聽String:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">聽strSrc);<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Encrypted聽String:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Use聽Def:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">聽te.Encrypt(strSrc,聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">));<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Use聽MD5:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">聽te.Encrypt(strSrc,聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">MD5</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Use聽SHA:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">聽te.Encrypt(strSrc,聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">SHA-1</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br />聽聽聽聽聽聽聽聽System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Use聽SHA-256:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">聽te.Encrypt(strSrc,聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">SHA-256</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br />聽聽聽聽}<br />}</span></div><br />鍙﹀錛屽湪javawebparts涓殑 RequestHelpers閲岀殑generateGUID鏂規硶涔熸秹鍙婂埌浜哅D5鐨勬柟娉曪紝浠g爜濡備笅:<br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,0)">聽String聽generateGUID(HttpServletRequest聽request)聽{<br /><br />聽聽聽聽String聽out聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">""</span><span style="COLOR: rgb(0,0,0)">;<br />聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">try</span><span style="COLOR: rgb(0,0,0)">聽{<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽Construct聽a聽string聽that聽is聽comprised聽of:<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽Remote聽IP聽Address聽+聽Host聽IP聽Address聽+聽Date聽(yyyyMMdd)聽+<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽Time聽(hhmmssSSa)聽+聽Requested聽Path聽+聽Session聽ID聽+<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽HashCode聽Of聽ParameterMap</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">聽聽聽聽聽聽StringBuffer聽sb聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽StringBuffer(</span><span style="COLOR: rgb(0,0,0)">1024</span><span style="COLOR: rgb(0,0,0)">);<br />聽聽聽聽聽聽sb.append(request.getRemoteAddr());<br />聽聽聽聽聽聽InetAddress聽ia聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽InetAddress.getLocalHost();<br />聽聽聽聽聽聽sb.append(ia.getHostAddress());<br />聽聽聽聽聽聽sb.append(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽SimpleDateFormat(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">yyyyMMddhhmmssSSa</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">).format(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽Date()));<br />聽聽聽聽聽聽String聽path聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽request.getServletPath();<br />聽聽聽聽聽聽String聽pathInfo聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽request.getPathInfo();<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">聽(pathInfo聽</span><span style="COLOR: rgb(0,0,0)">!=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">null</span><span style="COLOR: rgb(0,0,0)">)聽{<br />聽聽聽聽聽聽聽聽path聽</span><span style="COLOR: rgb(0,0,0)">+=</span><span style="COLOR: rgb(0,0,0)">聽pathInfo;<br />聽聽聽聽聽聽}<br />聽聽聽聽聽聽sb.append(path);<br />聽聽聽聽聽聽sb.append(request.getSession(</span><span style="COLOR: rgb(0,0,255)">false</span><span style="COLOR: rgb(0,0,0)">));<br />聽聽聽聽聽聽sb.append(request.getParameterMap().hashCode());<br />聽聽聽聽聽聽String聽str聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽sb.toString();<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽Now聽encode聽the聽string聽using聽an聽MD5聽encryption聽algorithm.</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">聽聽聽聽聽聽MessageDigest聽md聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽MessageDigest.getInstance(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">md5</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />聽聽聽聽聽聽md.update(str.getBytes());<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽digest聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽md.digest();<br />聽聽聽聽聽聽StringBuffer聽hexStr聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽StringBuffer(</span><span style="COLOR: rgb(0,0,0)">1024</span><span style="COLOR: rgb(0,0,0)">);<br />聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">for</span><span style="COLOR: rgb(0,0,0)">聽(</span><span style="COLOR: rgb(0,0,255)">int</span><span style="COLOR: rgb(0,0,0)">聽i聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">;聽i聽</span><span style="COLOR: rgb(0,0,0)"><</span><span style="COLOR: rgb(0,0,0)">聽digest.length;聽i</span><span style="COLOR: rgb(0,0,0)">++</span><span style="COLOR: rgb(0,0,0)">)聽{<br />聽聽聽聽聽聽聽聽str聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽Integer.toHexString(</span><span style="COLOR: rgb(0,0,0)">0xFF</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">&</span><span style="COLOR: rgb(0,0,0)">聽digest[i]);<br />聽聽聽聽聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">聽(str.length()聽</span><span style="COLOR: rgb(0,0,0)"><</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">2</span><span style="COLOR: rgb(0,0,0)">)聽{<br />聽聽聽聽聽聽聽聽聽聽str聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">聽str;<br />聽聽聽聽聽聽聽聽}<br />聽聽聽聽聽聽聽聽hexStr.append(str);<br />聽聽聽聽聽聽}<br />聽聽聽聽聽聽out聽</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">聽hexStr.toString();<br />聽聽聽聽}聽</span><span style="COLOR: rgb(0,0,255)">catch</span><span style="COLOR: rgb(0,0,0)">聽(NoSuchAlgorithmException聽nsae)聽{<br />聽聽聽聽聽聽log.error(nsae);<br />聽聽聽聽}聽</span><span style="COLOR: rgb(0,0,255)">catch</span><span style="COLOR: rgb(0,0,0)">聽(UnknownHostException聽uhe)聽{<br />聽聽聽聽聽聽log.error(uhe);<br />聽聽聽聽}<br />聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽Return聽the聽encrypted聽string.聽聽It聽should聽be聽unique聽based聽on聽the<br />聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽components聽that聽comprise聽the聽plain聽text聽string,聽and聽should聽always聽be<br />聽聽聽聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽32聽characters聽thanks聽to聽the聽MD5聽algorithm.</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">聽聽聽聽</span><span style="COLOR: rgb(0,0,255)">return</span><span style="COLOR: rgb(0,0,0)">聽out;<br /><br />聽聽}聽</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">聽End聽generateGUID().</span></div><br /><br />銆銆2錛夌閽ュ姞瀵嗭細<br /><br />銆銆娑堟伅鎽樿鍙兘媯鏌ユ秷鎭殑瀹屾暣鎬э紝浣嗘槸鍗曞悜鐨勶紝瀵規槑鏂囨秷鎭茍涓嶈兘鍔犲瘑錛岃鍔犲瘑鏄庢枃鐨勬秷鎭殑璇濓紝灝辮浣跨敤鍏朵粬鐨勭畻娉曪紝瑕佺‘淇濇満瀵嗘э紝鎴戜滑闇瑕佷嬌鐢ㄧ閽ュ瘑鐮佹湳鏉ヤ氦鎹㈢鏈夋秷鎭?br /><br />銆銆榪欑鏈濂界悊瑙o紝浣跨敤瀵圭О綆楁硶銆傛瘮濡傦細A鐢ㄤ竴涓瘑閽ュ涓涓枃浠跺姞瀵嗭紝鑰孊璇誨彇榪欎釜鏂囦歡鐨勮瘽錛屽垯闇瑕佸拰A涓鏍風殑瀵嗛挜錛屽弻鏂瑰叡浜竴涓閽ワ紙鑰屽湪web鐜涓嬶紝縐侀挜鍦ㄤ紶閫掓椂瀹規槗琚睛鍚級錛?br /><br />銆銆浣跨敤縐侀挜鍔犲瘑鐨勮瘽錛岄鍏堥渶瑕佷竴涓瘑閽ワ紝鍙敤javax.crypto.KeyGenerator浜х敓涓涓瘑閽?java.security.Key), 鐒跺悗浼犻掔粰涓涓姞瀵嗗伐鍏?javax.crypto.Cipher),璇ュ伐鍏峰啀浣跨敤鐩稿簲鐨勭畻娉曟潵榪涜鍔犲瘑錛屼富瑕佸縐扮畻娉曟湁錛欴ES錛堝疄闄呭瘑閽ュ彧鐢ㄥ埌56 浣嶏級錛孉ES錛堟敮鎸佷笁縐嶅瘑閽ラ暱搴︼細128銆?92銆?56浣嶏級錛岄氬父棣栧厛128浣嶏紝鍏朵粬鐨勮繕鏈塂ESede絳夛紝jdk1.5縐嶄篃鎻愪緵浜嗗瀵圭О綆楁硶鐨勬敮鎸侊紝浠ヤ笅渚嬪瓙浣跨敤AES綆楁硶鏉ュ姞瀵嗭細<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />*PrivateExmaple.java<br />*Copyright聽2005-2-16<br /></span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽javax.crypto.Cipher;<br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽javax.crypto.KeyGenerator;<br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽java.security.Key;<br /><br /></span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />*縐侀垍鍔犲瘑錛屼繚璇佹秷鎭満瀵嗘?br /></span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)">聽PrivateExample{<br />銆</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)">聽main(String[]聽args)聽</span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)">聽Exception{<br />銆銆</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">(args.length</span><span style="COLOR: rgb(0,0,0)">!=</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">){<br />銆銆銆System.err.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Usage:java聽PrivateExample聽<text></span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆銆System.exit(</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆}<br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽plainText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">args[</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">].getBytes(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /><br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">閫氳繃KeyGenerator褰㈡垚涓涓猭ey</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nStart聽generate聽AES聽key</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆KeyGenerator聽keyGen</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">KeyGenerator.getInstance(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">AES</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆keyGen.init(</span><span style="COLOR: rgb(0,0,0)">128</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆Key聽key</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">keyGen.generateKey();<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Finish聽generating聽DES聽key</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /><br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">鑾峰緱涓涓閳呭姞瀵嗙被Cipher錛孍CB鏄姞瀵嗘柟寮忥紝PKCS5Padding鏄~鍏呮柟娉?/span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆Cipher聽cipher</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">Cipher.getInstance(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">AES/ECB/PKCS5Padding</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\n</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">cipher.getProvider().getInfo());<br /><br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">浣跨敤縐侀垍鍔犲瘑</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nStart聽encryption:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆cipher.init(Cipher.ENCRYPT_MODE,key);<br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽cipherText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">cipher.doFinal(plainText);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Finish聽encryption:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽String(cipherText,</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br /><br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nStart聽decryption:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆cipher.init(Cipher.DECRYPT_MODE,key);<br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽newPlainText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">cipher.doFinal(cipherText);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Finish聽decryption:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /><br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽String(newPlainText,</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br /><br />銆}<br />}</span></div><br />銆銆3錛夊叕閽ュ姞瀵嗭細<br /><br />銆銆涓婇潰鎻愬埌錛岀閽ュ姞瀵嗛渶瑕佷竴涓叡浜殑瀵嗛挜錛岄偅涔堝浣曚紶閫掑瘑閽ュ憿錛焪eb鐜涓嬶紝鐩存帴浼犻掔殑璇濆緢瀹規槗琚睛鍚埌錛屽垢濂芥湁浜嗗叕閽ュ姞瀵嗙殑鍑虹幇銆傚叕閽ュ姞瀵嗕篃鍙笉瀵圭О鍔犲瘑錛屼笉瀵圭О綆楁硶浣跨敤涓瀵瑰瘑閽ュ錛屼竴涓叕閽ワ紝涓涓閽ワ紝浣跨敤鍏挜鍔犲瘑鐨勬暟鎹紝鍙湁縐侀挜鑳借В寮錛堝彲鐢ㄤ簬鍔犲瘑錛夛紱鍚屾椂錛屼嬌鐢ㄧ閽ュ姞瀵嗙殑鏁版嵁錛屽彧鏈夊叕閽ヨ兘瑙e紑錛堢鍚嶏級銆備絾鏄熷害寰堟參錛堟瘮縐侀挜鍔犲瘑鎱?00鍒?000鍊嶏級錛屽叕閽ョ殑涓昏綆楁硶鏈塕SA錛岃繕鍖呮嫭Blowfish,Diffie-Helman絳夛紝 jdk1.5縐嶆彁渚涗簡瀵筊SA鐨勬敮鎸侊紝鏄竴涓敼榪涚殑鍦版柟錛?<br /><br /><div style="BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />*PublicExample.java<br />*Copyright聽2005-2-16<br /></span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽java.security.Key;<br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽javax.crypto.Cipher;<br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽java.security.KeyPairGenerator;<br /></span><span style="COLOR: rgb(0,0,255)">import</span><span style="COLOR: rgb(0,0,0)">聽java.security.KeyPair;<br /></span><span style="COLOR: rgb(0,128,0)">/**</span><span style="COLOR: rgb(0,128,0)"><br />*涓涓畝鍗曠殑鍏垍鍔犲瘑渚嬪瓙,Cipher綾諱嬌鐢↘eyPairGenerator鐢熸垚鐨勫叕閳呭拰縐侀垍<br /></span><span style="COLOR: rgb(0,128,0)">*/</span><span style="COLOR: rgb(0,0,0)"><br /></span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">class</span><span style="COLOR: rgb(0,0,0)">聽PublicExample{<br />銆</span><span style="COLOR: rgb(0,0,255)">public</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">static</span><span style="COLOR: rgb(0,0,0)">聽</span><span style="COLOR: rgb(0,0,255)">void</span><span style="COLOR: rgb(0,0,0)">聽main(String[]聽args)聽</span><span style="COLOR: rgb(0,0,255)">throws</span><span style="COLOR: rgb(0,0,0)">聽Exception{<br />銆銆</span><span style="COLOR: rgb(0,0,255)">if</span><span style="COLOR: rgb(0,0,0)">(args.length</span><span style="COLOR: rgb(0,0,0)">!=</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">){<br />銆銆銆System.err.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Usage:java聽PublicExample聽<text></span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆銆System.exit(</span><span style="COLOR: rgb(0,0,0)">1</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆}<br /><br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽plainText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">args[</span><span style="COLOR: rgb(0,0,0)">0</span><span style="COLOR: rgb(0,0,0)">].getBytes(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">鏋勬垚涓涓猂SA瀵嗛挜</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nStart聽generating聽RSA聽key</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆KeyPairGenerator聽keyGen</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">KeyPairGenerator.getInstance(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">RSA</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆keyGen.initialize(</span><span style="COLOR: rgb(0,0,0)">1024</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆KeyPair聽key</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">keyGen.generateKeyPair();<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Finish聽generating聽RSA聽key</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br /><br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">鑾峰緱涓涓猂SA鐨凜ipher綾伙紝浣跨敤鍏垍鍔犲瘑</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆Cipher聽cipher</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">Cipher.getInstance(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">RSA/ECB/PKCS1Padding</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\n</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">+</span><span style="COLOR: rgb(0,0,0)">cipher.getProvider().getInfo());<br /><br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nStart聽encryption</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆cipher.init(Cipher.ENCRYPT_MODE,key.getPublic());<br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽cipherText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">cipher.doFinal(plainText);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Finish聽encryption:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽String(cipherText,</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br /><br />銆銆</span><span style="COLOR: rgb(0,128,0)">//</span><span style="COLOR: rgb(0,128,0)">浣跨敤縐侀垍瑙e瘑</span><span style="COLOR: rgb(0,128,0)"><br /></span><span style="COLOR: rgb(0,0,0)">銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">\nStart聽decryption</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆cipher.init(Cipher.DECRYPT_MODE,key.getPrivate());<br />銆銆</span><span style="COLOR: rgb(0,0,255)">byte</span><span style="COLOR: rgb(0,0,0)">[]聽newPlainText</span><span style="COLOR: rgb(0,0,0)">=</span><span style="COLOR: rgb(0,0,0)">cipher.doFinal(cipherText);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">Finish聽decryption:</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">);<br />銆銆System.out.println(</span><span style="COLOR: rgb(0,0,255)">new</span><span style="COLOR: rgb(0,0,0)">聽String(newPlainText,</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">UTF8</span><span style="COLOR: rgb(0,0,0)">"</span><span style="COLOR: rgb(0,0,0)">));<br />銆}<br />}</span></div></span> </a> <img src ="http://www.tkk7.com/wuxufeng8080/aggbug/78466.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wuxufeng8080/" target="_blank">椋庝漢鍥?/a> 2006-11-01 14:07 <a href="http://www.tkk7.com/wuxufeng8080/articles/78466.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>BMP銆丟IF鍜孞PEG鏂囦歡鏍煎紡綆浠?/title><link>http://www.tkk7.com/wuxufeng8080/articles/57060.html</link><dc:creator>椋庝漢鍥?/dc:creator><author>椋庝漢鍥?/author><pubDate>Fri, 07 Jul 2006 00:10:00 GMT</pubDate><guid>http://www.tkk7.com/wuxufeng8080/articles/57060.html</guid><description><![CDATA[ <div id="ogcquqw" class="postcontent"> <span id="qu8e8kk" class="line">銆銆鍥捐薄鏂囦歡灝辨槸鎻忕粯浜嗕竴騫呭浘璞$殑璁$畻鏈虹鐩樻枃浠躲傚艦鎴愭暟瀛楀浘璞℃暟鎹悗錛屽皢鍏跺瓨鍌ㄥ湪璁$畻鏈洪噷鐨勬柟娉曟湁2縐嶏紝鍗充綅鏄犲皠鍜屽悜閲忓鐞嗘柟寮忋?br />銆銆鎴戜滑榪欓噷涓昏璁ㄨ鐨勬槸浣嶅浘銆備笉鍚屽浘璞¤蔣浠跺嚑涔庨兘鐢ㄥ悇縐嶇殑鏂規硶澶勭悊鍥捐薄錛屽浘璞℃牸寮忎篃澶氱澶氭牱錛屽畠涓昏鍖呮嫭鏂囦歡璇嗗埆澶村拰鍥捐薄鏁版嵁銆傛枃浠惰瘑鍒ご鐢ㄦ潵璁╄綆楁満鍒ゆ柇鏄摢縐嶆枃浠舵牸寮忥紝鍥捐薄鏁版嵁鍖呭惈浜嗘暣涓鍥捐薄鎻忕粯鐩稿叧鏁版嵁錛屽寘鎷皟鑹叉澘銆佷綅鍥炬槧璞$瓑銆傛牴鎹帇緙╃畻娉曚笉鍚岋紝鏄犺薄鏂瑰紡涔熶笉鍚岋紝涓嬮潰綆瑕佷粙緇嶄竴涓嬪帇緙╃畻娉曘?</span> <p> <span id="ya8eiwg" class="line"> <b> <font color="#5288c7">涓銆?琛岀▼闀垮害鍘嬬緝</font> </b> <br />銆銆鍘熺悊鏄皢涓鎵弿琛屼腑鐨勯鑹插肩浉鍚岀殑鐩擱偦鍍忕礌鐢ㄤ竴涓鏁板煎拰閭d簺鍍忕礌鐨勯鑹插兼潵浠f浛銆備緥濡?aaabccccccddeee錛屽垯鍙敤3a1b6c2d3e鏉ヤ唬鏇褲傚浜庢嫢鏈夊ぇ闈㈢Н錛岀浉鍚岄鑹插尯鍩熺殑鍥懼儚錛岀敤RLE鍘嬬緝鏂規硶闈炲父鏈夋晥銆傜敱RLE鍘熺悊媧劇敓鍑鴻澶氬叿浣撹紼嬪帇緙╂柟娉? <br />銆銆1.PCX琛岀▼鍘嬬緝鏂規硶: 璇ョ畻娉曞疄闄呬笂鏄綅鏄犲皠鏍煎紡鍒板帇緙╂牸寮忕殑杞崲綆楁硶錛岃綆楁硶瀵逛簬榪炵畫鍑虹幇1嬈$殑瀛楄妭Ch錛岃嫢Ch>0xc0鍒欏帇緙╂椂鍦ㄨ瀛楄妭鍓嶅姞涓?xc1錛屽惁鍒欑洿鎺ヨ緭鍑篊h錛屽浜庤繛緇嚭鐜癗 嬈$殑瀛楄妭Ch錛屽垯鍘嬬緝鎴?xc0錛婲錛孋h榪欎袱涓瓧鑺傦紝鍥犺孨鏈澶у彧鑳戒負ff錛峜0=3fh(鍗佽繘鍒朵負63)錛屽綋N澶т簬63鏃訛紝 鍒欓渶鍒嗗嬈″帇緙┿?<br />銆銆2.BI_RLE8鍘嬬緝鏂規硶:鍦╓INDOWS鐨勪綅鍥炬枃浠朵腑閲囩敤浜嗚繖縐嶅帇緙╂柟娉曘傝鍘嬬緝鏂規硶緙栫爜涔熸槸浠ヤ袱涓瓧鑺備負鍩烘湰鍗曚綅銆傚叾涓涓涓瓧鑺傝瀹氫簡鐢ㄧ浜屼釜瀛楄妭鎸囧畾鐨勯鑹查噸澶嶆鏁般?濡傜紪鐮?0504琛ㄧず浠庡綋鍓嶄綅緗紑濮嬭繛緇樉紺?涓鑹插間負04鐨勫儚绱犮傚綋絎簩涓瓧鑺備負闆舵椂絎簩涓瓧鑺傛湁鐗規畩鍚箟:0琛ㄧず琛屾湯;1琛ㄧず鍥炬湯;2杞箟鍚庨潰2涓瓧鑺傦紝 榪欎袱涓瓧鑺傚垎鍒〃紺轟笅涓鍍忕礌鐩稿浜庡綋鍓嶄綅緗殑姘村鉤浣嶇Щ鍜屽瀭鐩翠綅縐匯傝繖縐嶅帇緙╂柟娉曟墍鑳藉帇緙╃殑鍥懼儚鍍忕礌浣嶆暟鏈澶т負8浣?256鑹?鍥懼儚銆?br />銆銆3.BI_RLE鍘嬬緝鏂規硶: 璇ユ柟娉曚篃鐢ㄤ簬WINDOWS浣嶅浘鏂囦歡涓紝瀹冧笌 BI_RLE8緙栫爜綾諱技錛屽敮涓涓嶅悓鏄?BI_RLE4鐨勪竴涓瓧鑺傚寘鍚簡涓や釜鍍忕礌鐨勯鑹詫紝鍥犳錛屽畠鍙兘鍘嬬緝鐨勯鑹叉暟涓嶈秴榪?6鐨勫浘鍍忋傚洜鑰岃繖縐嶅帇緙╁簲鐢ㄨ寖鍥存湁闄愩?<br />銆銆4.绱х緝浣嶅帇緙╂柟娉?Packbits):璇ユ柟娉曟槸鐢ㄤ簬Apple鍏徃鐨凪acintosh鏈轟笂鐨勪綅鍥炬暟鎹帇緙?鏂規硶錛?TIFF 瑙勮寖涓嬌鐢ㄤ簡榪欑鏂規硶錛?榪欑鍘嬬緝鏂規硶涓嶣I_RLE8鍘嬬緝鏂規硶鐩鎬技錛屽1c1c1c2132325648 鍘嬬緝涓?83 1c 21 81 32 56 48錛屾樉鑰屾槗瑙侊紝 榪欑鍘嬬緝鏂規硶鏈濂芥儏鍐墊槸姣忚繛緇?28涓瓧鑺傜浉鍚岋紝榪?28涓瓧鑺傚彲鍘嬬緝涓轟竴涓暟鍊?f銆傝繖縐嶆柟娉曡繕鏄潪甯告湁鏁堢殑銆?</span> </p> <p> <span id="yyqe2uw" class="line"> <b> <font color="#5288c7">浜屻侀湇澶浖緙栫爜鍘嬬緝:</font> </b> <br />銆銆涔熸槸涓縐嶅父鐢ㄧ殑鍘嬬緝鏂規硶銆傛槸1952騫翠負鏂囨湰鏂囦歡寤虹珛鐨勶紝鍏跺熀鏈師鐞嗘槸棰戠箒浣跨敤鐨勬暟鎹敤杈冪煭鐨勪唬鐮佷唬鏇匡紝寰堝皯浣跨敤鐨勬暟鎹敤杈冮暱鐨勪唬鐮佷唬鏇匡紝姣忎釜鏁版嵁鐨勪唬鐮佸悇涓嶇浉鍚屻傝繖浜涗唬鐮侀兘鏄簩榪涘埗鐮侊紝涓旂爜鐨勯暱搴︽槸鍙彉鐨勩傚: 鏈変竴涓師濮嬫暟鎹簭鍒楋紝ABACCDAA鍒欑紪鐮佷負A(0)錛孊(10)錛孋(110),(D111)錛屽帇緙╁悗涓?10011011011100銆備駭鐢熼湇澶浖緙栫爜闇瑕佸鍘熷鏁版嵁鎵弿涓ら亶錛岀涓閬嶆壂鎻忚綺劇‘鍦扮粺璁″嚭鍘熷鏁版嵁涓殑姣忎釜鍊煎嚭鐜扮殑棰戠巼錛岀浜岄亶鏄緩绔嬮湇澶浖鏍戝茍榪涜緙栫爜錛岀敱浜庨渶瑕佸緩绔嬩簩鍙夋爲騫墮亶鍘嗕簩鍙夋爲鐢熸垚緙栫爜錛屽洜姝ゆ暟鎹帇緙╁拰榪樺師閫熷害閮借緝鎱紝浣嗙畝鍗曟湁鏁堬紝鍥犺屽緱鍒板箍娉涚殑搴旂敤銆?/span> </p> <p> <span id="yaqc8mw" class="line"> <b> <font color="#5288c7">涓夈丩ZW鍘嬬緝鏂規硶</font> </b> <br />銆銆LZW鍘嬬緝鎶鏈瘮鍏跺畠澶у鏁板帇緙╂妧鏈兘澶嶆潅錛?鍘嬬緝鏁堢巼涔熻緝楂樸傚叾鍩烘湰鍘熺悊鏄妸姣忎竴涓涓嬈″嚭鐜扮殑瀛楃涓茬敤涓涓暟鍊兼潵緙栫爜錛屽湪榪樺師紼嬪簭涓啀灝嗚繖涓暟鍊艱繕鎴愬師鏉ョ殑瀛楃 涓詫紝濡傜敤鏁板?x100浠f浛瀛楃涓?abccddeee"榪欐牱姣忓綋鍑虹幇璇ュ瓧絎︿覆鏃訛紝閮界敤0x100浠f浛錛岃搗鍒頒簡鍘嬬緝鐨勪綔鐢ㄣ?鑷充簬0x100涓庡瓧絎︿覆鐨勫搴斿叧緋誨垯鏄湪鍘嬬緝榪囩▼涓姩鎬佺敓鎴愮殑錛岃屼笖榪欑瀵瑰簲鍏崇郴鏄殣鍚湪鍘嬬緝鏁版嵁涓紝闅忕潃瑙e帇緙╃殑榪涜榪欏紶緙栫爜琛ㄤ細浠庡帇緙╂暟鎹腑閫愭寰楀埌鎭㈠錛屽悗闈㈢殑鍘嬬緝鏁版嵁鍐嶆牴鎹墠闈㈡暟鎹駭鐢熺殑瀵瑰簲鍏崇郴浜х敓鏇村鐨勫搴斿叧緋匯傜洿鍒板帇緙╂枃浠剁粨鏉熶負姝€侺ZW鏄彲閫嗙殑錛?鎵鏈変俊鎭叏閮ㄤ繚鐣欍?/span> </p> <p> <span id="c242agw" class="line"> <b> <font color="#5288c7">鍥涖佺畻鏈帇緙╂柟娉?/font> </b> <br />銆銆綆楁湳鍘嬬緝涓庨湇澶浖緙栫爜鍘嬬緝鏂規硶綾諱技錛屽彧涓嶈繃瀹冩瘮闇嶅か鏇肩紪鐮佹洿鍔犳湁鏁堛傜畻鏈帇緙╅傚悎浜庣敱鐩稿悓鐨勯噸澶嶅簭鍒楃粍鎴愮殑鏂囦歡錛岀畻鏈帇緙╂帴榪戝帇緙╃殑鐞嗚鏋侀檺銆傝繖縐嶆柟娉曪紝鏄皢涓嶅悓鐨勫簭鍒楁槧鍍忓埌0鍒?涔嬮棿鐨勫尯鍩熷唴錛岃鍖哄煙琛ㄧず鎴愬彲鍙樼簿搴?浣嶆暟 )鐨勪簩榪涘埗灝忔暟錛岃秺涓嶅父瑙佺殑鏁版嵁瑕佺殑綺懼害瓚婇珮(鏇村鐨勪綅鏁?錛岃繖縐嶆柟娉曟瘮杈冨鏉傦紝鍥犺屼笉澶父鐢ㄣ?/span> </p> <p> <span id="ou2g2ko" class="line"> <b> <font color="#5288c7">浜斻?JPEG( 鑱斿悎鎽勫獎涓撳緇?Joint Photographic Exprerts Group)</font> </b> <br />銆銆JPEG鏍囧噯涓庡叾瀹冪殑鏍囧噯涓嶅悓錛屽畠瀹氫箟浜嗕笉鍏煎鐨勭紪鐮佹柟娉曪紝鍦ㄥ畠鏈甯哥敤鐨勬ā寮忎腑錛屽畠鏄甫澶辯湡鐨勶紝涓涓粠JPEG鏂囦歡鎭㈠鍑烘潵鐨勫浘鍍忎笌鍘熷鍥懼儚鎬繪槸涓嶅悓鐨勶紝浣嗘湁鎹熷帇緙╅噸寤哄悗鐨勫浘鍍忓父甯告瘮鍘熷鍥懼儚鐨勬晥鏋滄洿濂姐侸PEG鐨勫彟涓涓樉钁楃殑鐗圭偣鏄畠鐨勫帇緙╂瘮渚嬬浉褰撻珮錛屽師鍥懼儚澶у皬涓庡帇緙╁悗鐨勫浘鍍忓ぇ灝忕浉姣旓紝姣斾緥鍙互浠?錛呭埌80锝?0錛呬笉絳夈?榪欑鏂規硶鏁?鏋滀篃濂斤紝閫傚悎澶氬獟浣撶郴緇熴?/span> </p> <p> <span id="2gikmwy" class="line">銆銆浠嬬粛瀹屼簡鍘嬬緝綆楁硶錛屾垜浠潵綆瑕佷粙緇嶄竴涓嬩笁縐嶄綅鍥炬牸寮忕殑寮傚悓鍜屽畠浠箣闂寸殑鐩鎬簰杞崲銆?br />銆銆<b>1. bmp鍥捐薄</b><br />銆銆銆路 浣嶅浘鏂囦歡澶?BITMAPHEADER)鏁版嵁緇撴瀯<br />銆銆銆路 浣嶅浘淇℃伅(BITMAPINFO)鏁版嵁緇撴瀯<br />銆銆銆路 浣嶅浘闃靛垪</span> </p> <p> <span id="u4o8emm" class="line">銆銆1)浣嶅浘鏂囦歡澶存暟鎹粨鏋勫寘鍚獴MP鍥捐薄鏂囦歡鐨勭被鍨嬨佹樉紺哄唴瀹圭瓑淇℃伅銆?br />銆銆Typedef struct{<br />銆銆銆銆銆銆Int bfType; //must be "BM"<br />銆銆銆銆銆銆Long bfSize; //浣嶅浘澶у皬<br />銆銆銆銆銆銆Int bfReserved1;//must be "0"<br />銆銆銆銆銆銆Int bfReserved2;//must be "0"<br />銆銆銆銆銆銆Long bfOffBits;//浣嶅浘闃靛垪鐨勮搗濮嬩綅緗?br />銆銆}BITMAPEFILEHEADER;</span> </p> <p> <span id="giemg2q" class="line">銆銆2)浣嶅浘淇℃伅鏁版嵁緇撴瀯鐢盉ITMAPINFOHEADER鍜孯GBQUAD涓や釜鏁版嵁緇撴瀯緇勬垚錛?br />銆銆typedef struct{<br />銆銆銆銆銆銆BITMAPINFOHEADER bmiHeader;<br />銆銆銆銆銆銆RGBQUAD bmiColors[];<br />銆銆}BITMAPINFO</span> </p> <p> <span id="sseqcce" class="line">銆銆鍏朵腑BITMAPINFOHEADER鏁版嵁緇撴瀯鍖呭惈浜嗘湁鍏矪MP鍥捐薄鐨勫銆侀珮銆佸帇緙╂柟娉曠瓑淇℃伅銆?br />銆銆鏁版嵁緇撴瀯RGBQUAD瀹氫箟涓縐嶉鑹層?/span> </p> <p> <span id="2qsuwow" class="line">銆銆3錛変綅鍥鵑樀鍒?br />銆銆浣嶅浘闃靛垪璁板綍浜嗗浘璞$殑姣忎竴涓薄绱犲箋備粠鍥捐薄鐨勫乏涓嬭寮濮嬮愯鎵弿鍥捐薄銆備粠宸﹀埌鍙籌紝浠庝笂鍒頒笅錛屽皢鍥捐薄鐨勮薄绱犲奸愪竴璁板綍涓嬫潵錛岃繖浜涜褰曡薄绱犲肩殑瀛楄妭緇勬垚浜嗕綅鍥鵑樀鍒椼?br />銆銆浣嶅浘闃靛垪鏁版嵁鐨勫瓨鍌ㄦ牸寮忔湁鍘嬬緝鍜岄潪鍘嬬緝涓ょ鏍煎紡銆?br />銆銆1錛?闈炲帇緙╂牸寮?浣嶅浘涓殑姣忎竴涓偣鐨勮薄绱犲煎搴斾笌浣嶅浘闃靛垪鐨勮嫢騫蹭綅錛岃屼綅鍥鵑樀鍒楃殑鑻ュ共浣嶇敱鍥捐薄鐨勯珮搴︺佸搴﹀強鍥捐薄鐨勯鑹叉暟鍐沖畾銆?br />銆銆2錛?鍘嬬緝鏍煎紡 鍦╞mp鏍煎紡鏂囦歡涓紝Windows鏀寔BI-RLE8鍜孊I-RLE4涓ょ鍘嬬緝綾誨瀷鐨勫瓨鍌ㄦ牸寮忋?/span> </p> <p> <span id="qc4g4mo" class="line">銆銆<b>2銆丟IF鍥捐薄鏂囦歡鏍煎紡</b><br />銆銆GIF鐨勫叏縐版槸Graphics Interchange Format,.璇戝仛鍥懼艦浜ゆ崲鏍煎紡銆侴IF鏄竴縐嶅叕鐢ㄧ殑鍥捐薄鏂囦歡鏍煎紡鏍囧噯錛屼絾瀹冨綊compuServe鍏徃鐗堟潈鎵鏈夈?br />GIF鏂囦歡緇撴瀯鍖呭惈涓涓枃浠跺ご錛?/span> <span id="yys2ogi" class="line">鍦ㄤ竴涓狦IF鏂囦歡涓鍏堢鍒扮殑鏄疓IF鐨勬爣蹇楋紝榪欎釜鏍囧織鍛婅瘔瑙g爜紼嬪簭榪欐槸涓狦IF鏂囦歡銆傝繖涓爣蹇楁槸3瀛楄妭鐨勪覆錛欸IF銆備竴涓狦IF鏂囦歡涓彲浠ュ瓨鏀懼騫呭浘璞★紝浣嗙粷澶у鏁扮殑鏂囦歡閮藉彧鍖呭惈涓騫呭浘璞°?br />銆銆鐒跺悗鏄睆騫曟弿榪板瓧(screen descriptor),璇存槑浜嗙敤鏉ョ敓鎴愮殑鏄劇ず鏂囦歡涓殑鍥捐薄鐨勬樉紺哄櫒鍒嗚鯨鐜囷紝鍒嗗埆琛ㄧず灞忓箷鐨勫鍜岄珮銆?br />銆銆绱ц窡涓嬫潵鐨勪竴涓瓧鑺傛槸鍏ㄥ眬鏍囧織錛屽叾浣庝笁浣嶈鏄庝簡鍗沖皢紕板埌鐨勫浘璞℃槸澶氬皯棰滆壊鐨勩傛渶楂樹綅琛ㄧず鏄惁瀛樺湪涓涓叏灞鑹插僵琛ㄣ?br />銆銆鑳屾櫙鑹茶〃紺烘妸鑳屾櫙緗垚閫傚綋鐨勯鑹詫紝瀹為檯涓婃槸涓涓寚鍚戝叏灞鑹插僵琛ㄧ殑鏁般?br />銆銆Struct Global_Data{<br />銆銆銆銆Unsigned short screen_width;<br />銆銆銆銆Unsigned short screen_height;<br />銆銆銆銆Unsigned char background;<br />銆銆銆銆har tail='\0';<br />銆銆銆銆}<br />銆銆鎺ヤ笅鏉ユ槸鍏ㄥ眬鑹插僵琛紝鎸夐『搴忓瓨鏀炬墍鏈夌殑涓ヨ們錛屾瘡涓縐嶄弗鑲冪敱鑹插僵琛ㄧ殑涓欏規潵鎻忚堪錛屾瘡欏規槸3瀛楄妭錛屽垎鍒〃紺虹孩銆佺豢銆佽摑涓夌鍘熻壊鐨勫己搴︺傚叾闀垮害鏈夊叏灞鏍囧織鐨勪綆涓変綅琛ㄧず銆?br />銆銆浠ュ悗鐨勬暟鎹兘鏄眬閮ㄧ殑浜嗐傛槸浜涙暟鎹潡鐨勯泦鍚堛備笅闈㈡槸鍥捐薄鏁版嵁鍧楃殑緇撴瀯銆?br />銆銆Struct Local_Head{<br />銆銆銆銆銆銆Char heading=',';<br />銆銆銆銆銆銆Unsigned short image_left;//鍥捐薄鐨勫睆騫曚笂鏄劇ず鐨勮搗濮嬩綅緗?br />銆銆銆銆Unsigned short image_top;<br />銆銆銆銆Unsigned short image_width;<br />銆銆銆銆Unsigned short image-height;<br />銆銆銆銆Unsigned char local_flag;//灞閮ㄦ爣蹇?br />銆銆銆銆} </span> </p> <p> <span id="k4y2emm" class="line">銆銆灞閮ㄦ爣蹇楀拰 鍏ㄥ眬鏍囧織鐨勪笉鍚屼箣澶勫湪浜庢楂樹綅錛屽鏋滆繖浣嶈緗垚1鍒欒〃紺哄浘鍍忕殑浣嶅浘鏁版嵁鏄互闅旇鏂瑰紡瀛樻斁鐨勩備篃灝辨槸璇達紝鍦ㄨВ寮鐨勪綅鍥炬暟鎹腑錛岀涓琛屽瓨鏀劇殑鏄睆騫曚笂絎竴琛岋紝絎簩琛屽搴斿睆騫曚笂鐨勭9琛岋紝絎笁琛屽搴斿睆騫曚笂鐨勭17琛岋紝浠ユ閫掑--榪欐槸絎竴閬嶆壂鎻忥紱絎簩閬嶆壂鎻忔槸浠庡睆騫曚笂鐨勭5琛屽紑濮嬶紝涓よ涔嬮棿涔熸槸浠?閫掑錛涚涓夐亶鎵弿鏄粠灞忓箷涓婄殑絎?琛屽紑濮嬶紝涓よ涔嬮棿浠?閫掑錛涚鍥涢亶鎵弿錛屼篃鏄渶鍚庝竴閬嶏紝浠庣2琛屽紑濮嬶紝涓よ涔嬮棿浠?閫掑銆?/span> <span id="qikg4ey" class="line">闅旇瀛樻斁鐨凣IF鍥懼儚鍦ㄨ竟瑙g爜杈規樉紺虹殑鏃跺欏彲鍒嗘垚鍥涢亶鎵弿銆傜涓閬嶆壂鎻忚櫧鐒跺彧鏄劇ず浜嗘暣涓浘鍍忕殑鍏垎涔嬩竴錛岀浜岄亶鐨勬壂鎻忓悗涔熷彧鏄劇ず浜嗗洓鍒嗕箣涓錛屼絾榪欏凡緇忔妸鏁翠釜鍥懼儚鐨勬璨屾樉紺哄嚭鏉ヤ簡銆傚湪鏄劇ずGIF鍥懼儚鐨勬椂錛岄殧琛屽瓨鏀劇殑鍥懼儚浼氱粰浣犺繖鏍蜂竴涓嵃璞★細鍚戝畠鐨勬樉紺洪熷害浼間箮瑕佹瘮鍏朵粬鍥懼儚蹇竴浜涳紝榪欐槸闅旇瀛樻斁鐨勪紭鐐廣?br />銆銆鍦℅IF鍥懼儚鐨勭紪瑙g爜涓敤鍒頒簡LZW鍘嬬緝綆楁硶--鎶婅繖浜涘瓧絎︽祦杞崲鎴愬彟涓縐嶅艦寮忕殑浠g爜嫻侊紝瑙g爜榪囩▼鍒欐槸鎶婅繖縐嶄唬鐮佹祦榪樺師鎴愬師鏉ョ殑瀛楃嫻併?/span> </p> <p> <span id="oas2aau" class="line">銆銆<b>3銆丣PEG鍥捐薄鏂囦歡鏍煎紡</b><br />銆銆JPEG鏄疛oint Photographic Experts Group(鑱斿悎鎽勫獎涓撳灝忕粍)鐨勯瀛楁瘝緙╁啓銆侸PEG鐨勪富瑕佷綔鐢ㄦ槸鐢ㄤ簬鏁板瓧鍖栧浘璞$殑鏍囧噯緙栫爜鎶鏈侸PEG鍥捐薄鏂囦歡鏄竴縐嶈薄绱犳牸寮忔枃浠舵牸寮忥紝浣嗗畠姣旇濡傝薄GIF銆丅MP絳夊浘璞℃枃浠惰澶嶆潅鐨勫銆傛墍騫?鎴戜滑鍦ㄤ嬌鐢ㄧ敱JPEG緇勬垚鐨凧PEG搴撴椂,鍙瀵硅鏂囦歡鏍煎紡鏈変釜涓鑸殑浜嗚В灝卞彲浠ヤ簡銆傝屾病鏈夊繀瑕佸JPEG鏂囦歡鏍煎紡鍋氫竴涓叏闈㈢粏鑷寸殑浜嗚В銆?br />銆銆JPEG鏍煎紡鏄鏈夋崯鐨勭紪鐮佹牸寮忥紝浣嗗鏋淕IF鏂囦歡姣旓紝浠栫粡榪囪В鐮佸悗鐨勯噸鏋勫浘璞¤姣擥IF鍥捐薄鏇存帴榪戜簬鍘熷鐨勫浘璞°?JPEG緙栫爜鎶鏈槸鐢遍鑹茶漿鎹€丏CT鍙樻崲銆佽繘琛岄噺鍖栥佺紪鐮併傚叾鍘嬬緝鏍煎紡鐢辮憲鍚嶇殑JPEG闆嗗洟鎵钁楃殑4.0鐗堟湰鐨勫簱鎵瀹氥?/span> </p> <p> <span id="moqkcu4" class="line">銆銆鍏充簬榪?縐嶅浘璞℃牸寮忕殑浜掔浉杞崲錛屼富瑕佹槸鐢╟璇█鎴朿++鍜屾眹緙栬璦錛屽洜涓鴻繖浜涜璦鍙互 鐩存帴榪涜搴曞眰鐨勬搷浣滐紝鎶婂浘璞¤В鍘嬬緝鍚庢寜鐢ㄥ彟涓縐嶆牸寮忚姹傝繘琛屽帇緙╁嵆鍙?br />鏈枃灞炶漿杞斤紝鍘熸枃鍦板潃錛?a >http://www.chinaaspx.com/comm/dotnetbbs/Showtopic.aspx?Forum_ID=44&Id=139926&PPage=1</a></span> </p> </div> <img src ="http://www.tkk7.com/wuxufeng8080/aggbug/57060.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.tkk7.com/wuxufeng8080/" target="_blank">椋庝漢鍥?/a> 2006-07-07 08:10 <a href="http://www.tkk7.com/wuxufeng8080/articles/57060.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>感谢您访问我们的网站,您可能还对以下资源感兴趣:</p> <a href="http://www.tkk7.com/" title="亚洲av成人片在线观看">亚洲av成人片在线观看</a> <div class="friend-links"> </div> </div> </footer> 主站蜘蛛池模板: <a href="http://www789789.com" target="_blank">亚欧免费一级毛片</a>| <a href="http://sjmthanks.com" target="_blank">国产黄色片免费看</a>| <a href="http://yijiazhiwei.com" target="_blank">精品久久久久国产免费</a>| <a href="http://yxjcgs.com" target="_blank">亚洲国产精品久久久久婷婷软件</a>| <a href="http://12345ww.com" target="_blank">一区二区三区免费高清视频</a>| <a href="http://96yizhi.com" target="_blank">亚洲国产成人影院播放</a>| <a href="http://av-fantasy.com" target="_blank">亚洲熟妇AV一区二区三区宅男</a>| <a href="http://doubaye.com" target="_blank">4虎永免费最新永久免费地址</a>| <a href="http://xuanboart.com" target="_blank">亚洲成Av人片乱码色午夜</a>| <a href="http://bii59.com" target="_blank">久久国产免费一区</a>| <a href="http://hgbookvip.com" target="_blank">亚洲最大在线观看</a>| <a href="http://ddhlj.com" target="_blank">久久电影网午夜鲁丝片免费</a>| <a href="http://sxhengshan.com" target="_blank">亚洲精华国产精华精华液</a>| <a href="http://zc-zk.com" target="_blank">亚洲成a人片在线观看日本麻豆</a>| <a href="http://yongfu-sh.com" target="_blank">一级做a免费视频观看网站</a>| <a href="http://yuyang0752.com" target="_blank">国产精品亚洲一区二区三区在线</a>| <a href="http://51xinshiji.com" target="_blank">久久这里只精品热免费99</a>| <a href="http://dunyny.com" target="_blank">亚洲精品国产免费</a>| <a href="http://bjgelinhotel.com" target="_blank">午夜老司机免费视频</a>| <a href="http://mordernshasha.com" target="_blank">一级黄色片免费观看</a>| <a href="http://344zx.com" target="_blank">久久久久久久亚洲Av无码</a>| <a href="http://93qsgy.com" target="_blank">好男人视频在线观看免费看片</a>| <a href="http://www769393.com" target="_blank">亚洲成AV人片在WWW</a>| <a href="http://njjngs.com" target="_blank">亚洲精品无码mv在线观看网站</a>| <a href="http://wwyw99977.com" target="_blank">四虎影视成人永久免费观看视频</a>| <a href="http://liangdy.com" target="_blank">亚洲制服丝袜中文字幕</a>| <a href="http://zjlxblog.com" target="_blank">久久亚洲欧洲国产综合</a>| <a href="http://xiaojiejieav.com" target="_blank">99久久免费看国产精品</a>| <a href="http://haohaoshuo.com" target="_blank">亚洲gay片在线gv网站</a>| <a href="http://dslygc.com" target="_blank">一区二区三区亚洲</a>| <a href="http://ybcin.com" target="_blank">亚洲精品456播放</a>| <a href="http://cnpc1002.com" target="_blank">日本阿v免费费视频完整版</a>| <a href="http://sqmdjz.com" target="_blank">一区二区免费在线观看</a>| <a href="http://saozib.com" target="_blank">亚洲综合色7777情网站777</a>| <a href="http://am3736.com" target="_blank">亚洲色无码专区在线观看</a>| <a href="http://yu388.com" target="_blank">免费观看一级毛片</a>| <a href="http://xx16xx.com" target="_blank">中文免费观看视频网站</a>| <a href="http://fenglufzjx.com" target="_blank">韩国免费A级毛片久久</a>| <a href="http://jxszzhzs.com" target="_blank">精品久久久久久亚洲中文字幕</a>| <a href="http://cao8080.com" target="_blank">亚洲一区二区成人</a>| <a href="http://456jjj.com" target="_blank">亚洲av综合avav中文</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>