javarc4
Ⅰ 求編程實現同步序列密碼(流密碼)的加解密系統,java或C都行。謝謝啦~
序列密碼
編輯
流密碼即序列密碼。
序列密碼也稱為流密碼(Stream Cipher),它是對稱密碼演算法的一種。序列密碼具有實現簡單、便於硬體實施、加解密處理速度快、沒有或只有有限的錯誤傳播等特點,因此在實際應用中,特別是專用或機密機構中保持著優勢,典型的應用領域包括無線通信、外交通信。 1949年Shannon證明了只有一次一密的密碼體制是絕對安全的,這給序列密碼技術的研究以強大的支持,序列密碼方案的發展是模仿一次一密系統的嘗試,或者說「一次一密」的密碼方案是序列密碼的雛形。如果序列密碼所使用的是真正隨機方式的、與消息流長度相同的密鑰流,則此時的序列密碼就是一次一密的密碼體制。若能以一種方式產生一隨機序列(密鑰流),這一序列由密鑰所確定,則利用這樣的序列就可以進行加密,即將密鑰、明文表示成連續的符號或二進制,對應地進行加密,加解密時一次處理明文中的一個或幾個比特。
序列密碼與分組密碼的對比
分組密碼以一定大小作為每次處理的基本單元,而序列密碼則是以一個元素(一個字母或一個比特)作為基本的處理單元。
序列密碼是一個隨時間變化的加密變換,具有轉換速度快、低錯誤傳播的優點,硬體實現電路更簡單;其缺點是:低擴散(意味著混亂不夠)、插入及修改的不敏感性。
分組密碼使用的是一個不隨時間變化的固定變換,具有擴散性好、插入敏感等優點;其缺點是:加解密處理速度慢、存在錯誤傳播。
序列密碼涉及到大量的理論知識,提出了眾多的設計原理,也得到了廣泛的分析,但許多研究成果並沒有完全公開,這也許是因為序列密碼目前主要應用於軍事和外交等機密部門的緣故。目前,公開的序列密碼演算法主要有RC4、SEAL等。
Ⅱ java poi 要導哪些包
poi-3.0-rc4-20070503.jarpoi-2.0-final-20040126.jarcommons-io-1.4.jarcommons-fileupload-1.2.1.jar
Ⅲ 從nsq隊列中取數據時會報java.lang.IllegalStateException: Queue full
在不對的時機操作 比如一入文件被蘆搭一個程陪碧拿序讀取並鎖定 這時你用java向慧蠢其中寫入內容 就會出現所謂的 illegalstateexception
Ⅳ java如何讀取一個加密後的.xls文件
近日來,研究了一下Excel Biff8(xls 97-2007)與OpenXML(ECMA-376)的加密文檔的讀取(這還是為了我們世界先進Grid而做的 ^__^)。有些成果,寫在這里,希望能給要做類似功能的XD們一些參考。
如有不詳,請聯系:[email protected] / [email protected]
前提:
1. 加密文檔:指Wookbook級的加密,就是在Save Excel文檔時在General Settings中設置open password之後的文檔;
2. 打開:需要用戶傳入密碼。並非破解。但請勿將本文方法添加暴力模塊使用 :-) ;
3. 本文涉及較多為,密鑰計算,關於解密細節請參考微軟相關文檔;
使用的加密演算法: RC4, SHA1, MD5, AES-128(其中RC4並不包含在所有版本的.NET Framework中,AES演算法可以在.NET Framework 3.5中找到)
本文示例依賴 .NET Framework 3.5
A. Biff8 的加密文檔讀取
1. 通過文檔中FILEPASS的record取得,文檔的加密信息(關於Biff文檔的格式問題,請參閱Biff的微軟文檔)
其中Biff8可以使用兩種方法加密:Biff8標准加密演算法和Biff8擴充加密演算法。本文主要討論最常用的Biff標准加密演算法
2. 通過FILEPASS的結構,獲得如下信息:
salt(加密隨機數,16 bytes)
password verifier (密碼效驗器,16 bytes)
password verifier hash(密碼效驗器Hash,16 bytes)
3. 通過以上信息,生成解密key。並通過密碼效驗器,驗證密碼:
i. 將密碼轉化成unicode數組,並進行MD5 Hash;
ii. 將hash結果與salt串聯,然後將byte數組,反復串聯16次(336 bytes) ,然後再進行MD5 Hash;
iii. 將上步hash結果的前五位,串聯上4 bytes的block值(在密碼驗證階段為0,在以後解密階段為block的index) ,然後進行MD5 Hash;
iv. 將上步hash結果的前16位,作為key
v. 使用RC4對稱加密演算法,將password verifier和password verifier hash分別解密,然後對password verifier的解密結果進行MD5 hash,其值應和password verifier hash的解密結果一致,即為密碼正確。
vi. 之後進行逐個record的解密。excel biff8加密原則基本為,record的標示不加密,長度不加密,個別record不加密(見文檔);另外,在record解密時,還需要通過block的值重新計算解密key,block的大小為1024.
4. 詳細請參照示例代碼;
B. OpenXML(ECMA-376) 加密文檔的讀取
1. 通常來說,xlsx文件相當於一個zip文件,可以用zip程序,直接打開。而在加密後,為了安全性考慮,微軟使用了 structured storage(一種OLE文檔存儲方式)存儲(可以用7-zip或者OLE document viewer打開,windows也有相應API來操作此類結構)。在上述文檔中,有一個叫做「EncryptedPackage」加密的package,就是一個zip包通過AES演算法進行加密之後的結果。我們將使用和A一樣的方式來檢查密碼,但生成key的方法不同;OpenXML的加密類型也有多種,我們這里就討論常用的用AES-128進行加密的流程;
2. 通過文檔的「EncryptedInfo」部分,需要過的一下信息(關於此部分的結構,請參考[MS-OFFCRYPTO].pdf)
salt(加密隨機數,16 bytes)
password verifier (密碼效驗器,16 bytes)
password verifier hash(密碼效驗器Hash,32 bytes)
3. 通過以上信息,生成解密key。並通過密碼效驗器,驗證密碼:
i. 首先,定義一個H函數,其有兩個輸入,內部使用SHA1演算法將兩個輸入串聯之後的結果hash返回;
ii. 先將salt與password(password的unicode數組)進行H計算,h = H(salt, password) ;
iii.然後設iterator為0x00000000,將其轉為4byte的數組,然後進行H計算,h1 = H(iterator, h);
iv.將上面的iterator遞增一,然後再與h1進行H計算,h2 = H(iterator,h1),然後將這個遞增和計算過程重復50000次,最後計算過的iterator為49999即可;
v. 現在有計算結果h50000,將h50000再與0x00000000(4 byte數組)進行H計算,Hfinal = H(h50000, 0x00000000);
vi. 生成一個64byte的數組,將每位都初始化成0x36,然後將這個數組與Hfinal異或;(關於這個地方,微軟文檔中寫的有錯誤,按照原文的方法生成的key不正確,要不是文檔的作者回信告訴我要使用這個法子,就算我想破頭也想不出來啊 T__T)
vii.將異或結果,進行SHA1 hash,結果的前16byte就是解密的key;
viii.初始化AES演算法,key長度為128,模式為ECB模式,Padding為none; 然後將password verifier 和password verifier hash分別解密;
ix. password verifier 解密後的SHA1 hash結果應該與password verifier hash解密後的前20byte相同;
4. 關於"EncryptedPackage" 的解密則更為簡單,只許將「EncryptedPackage」讀入,去除前8byte的size信息後,進行AES解密,即為未加密的標准openxml文檔。
參考:
[MS-OFFCRYPTO].pdf
[MS-XLS].pdf
ECMA-376 standards
Reply by "winnow", 2008-09-10, 1:17
-----------------------------------------------------
總結一下, 關於這兩種基於密碼的加密方法, 基本上都是基於RFC2898 建議, 思想是這樣:
輸入是用戶的密碼:password, 輸出是提供給加密函數的密鑰:key.
考慮安全, 需要使同樣的password生成的key不一樣, 這樣用相同的password加密後的結果就無法比較. 需要一個隨機數salt.
另外, 為了使暴力破解的代價增大, 考慮使用一個循環多次的過程, 需要循環次數:iteration_count.
概念上, 生成方法為: 將password和salt進行某種運算, 配合一個Hash函數, 以某種方式循環iteration_count次, 在最後的結果里取一部分作為key輸出.
具體參照RFC2898中的建議方法PBKDF1和PBKDF2.
這樣, 用戶輸入的密碼與一個隨機數組合, 經過一定代價的運算, 就生成了可以供加密函數使用的密鑰. 使用這個密鑰和一個加密函數, 就可以進行加密了.
在應用中, 為了快速判斷密碼是否錯誤. 生成一個隨機數verifier, 用一個Hash函數計算verifier的hash值:verifier_hash, 分別加密verifier和verifier_hash並保存.
解密的時候, 先分別解密出verifier和verifier_hash, 計算verifier的hash值, 與verifier_hash比較, 如果一致, 即說明密碼正確.
Ⅳ 求一個實現RC4加密演算法的第三方包,JAVA的
曾經實驗室的帶動,加上最近在上網路安全與管理的專業選修課,對加密演算法有了濃厚的興趣。老師留了一次作業,用自己的學號為密鑰,加密一句話,使用RC4加密演算法。
圖書館查找資料,發現RC4演算法還是比較容易理解的。於是動手實現出來。不多說廢話,還是貼代碼吧。我寫的注釋還算清楚。
先貼一個含main函數的核心演算法類,有測試,可以看看最後輸出了什麼^.^
import java.io.UnsupportedEncodingException;
public class Arithmetic {
public static void swap(int x,int y){
int temp;
temp=x;
x=y;
y=temp;
}
public static void main(String[] args) throws UnsupportedEncodingException {
// 密鑰(我的學號)
byte K[]={0,6,1,6,1,0,0,4};
int S[]=new int[256];//狀態矢量S
int T[]=new int[256];//臨時矢量T
// 初始化狀態矢量S,同時生成臨時矢量T
for(int i=0;i<256;i++){
S[i]= i;
T[i]=K[i%K.length];
}
//用T使S置換
{
int j=0;
for(int i=0;i<256;i++){
j=(j+(int)S[i]+(int)T[i])%256;
swap(S[i],S[j]);
}
}
int i = 0,j=0;
boolean tt=true;
int c=0;
int t;
byte k;//密鑰流的當前位元組
byte C[]="套范續".getBytes();
System.out.println(C[3]);
byte P[]=new byte[C.length];
while(c<6){
i=(i+1)%256;
j=(j+S[i])%256;
swap(S[i],S[j]);
t=((S[i]+S[j])%256);
k=(byte) S[t];
// C[c]=(byte) (k^P[c]);
// System.out.print(C[c]+" ");
P[c]=(byte) (k^C[c]);
System.out.print(P[c]+" ");
c++;
}
System.out.println(new String(P,"GBK"));
// byte rr[]={65};
// System.out.println(new String(rr));
}
}
再來貼一下以界面展示的代碼,比較長。用的就是普通的jsp+servlet。
核心類:
public class RC4 {
// 密鑰(我的學號)
byte K[]={0,6,1,6,1,0,0,4};
void swap(int x,int y){
int temp;
temp=x;
x=y;
y=temp;
}
public String encrypt(String plaintext){
String ciphertext=new String();
int S[]=new int[256];//狀態矢量S
int T[]=new int[256];//臨時矢量T
// 初始化狀態矢量S,同時生成臨時矢量T
for(int i=0;i<256;i++){
S[i]= i;
T[i]=K[i%K.length];
}
//用T使S置換
{
int j=0;
for(int i=0;i<256;i++){
j=(j+(int)S[i]+(int)T[i])%256;
swap(S[i],S[j]);
}
}
int i = 0,j=0;
int c=0;
int t;
byte k;//密鑰流的當前位元組
byte P[]=plaintext.getBytes();
byte C[]=new byte[P.length];
while(c<P.length){
i=(i+1)%256;
j=(j+S[i])%256;
swap(S[i],S[j]);
t=((S[i]+S[j])%256);
k=(byte) S[t];
C[c]=(byte) (k^P[c]);
System.out.print(C[c]+" ");
c++;
}
System.out.println(new String(C));
ciphertext=new String(C);
return ciphertext;
}
}
頁面:
home.jsp
<%@ page language="java" import="java.util.*,core.ChangeCharset" pageEncoding="GBK"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'home.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="styles.css">
<script type="text/javascript">
function doencrypt(){
document.form1.domethod.value="encrypt";
document.form1.submit();
}
function dodecipher(){
document.form1.domethod.value="decipher";
document.form1.submit();
}
</script>
</head>
<body>
<%@ include file="header.jsp" %>
<div id="show" >
<form name="form1" method="post" action="Manage">
<input type="hidden" name="domethod" />
請輸入一句話:<input type="text" name="plainText" />
<a href="javascript:void(0)" onclick="javascript:doencrypt();return false;">加密</a>
</br>
</br>
<%String cipher=(String)request.getAttribute("cipher");
if(cipher==null){
cipher="";
}
String plain1=(String)request.getAttribute("plain1");
if(plain1==null){
plain1="";
}
%>
所得密文:<input type="text" name="cipherText" value="<%=cipher %>" />
<a href="javascript:void(0)" onclick="javascript:dodecipher();return false;">解密</a>
</br>
</br>
所得明文:<input type="text" name="getPlain" value="<%=plain1 %>" />
</form>
</div>
<%@ include file="footer.jsp" %>
</body>
</html>
header.jsp(這個沒什麼意思,但還是給出來吧,給初學html的朋友一些借鑒)
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<div id="header" align="center">
<h1>RC4加密演算法測試系統</h1>
<hr>
</div>
footer.jsp
<%@ page language="java" import="java.util.*" pageEncoding="gb2312"%>
<div align="center">
<hr>
<table>
<tr><td>Powered by Tasu</td></tr>
<tr><td>Copyright@Tasusparty Studio 2009-2010 All rights reserved</td></tr>
</table>
</div>
styles.css(給出來省事一些,諸位看起來方便)
body{
margin:0px;
padding:0px;
background: #E6EAE9;
font-family: "Lucida Sans Unicode", "宋體", "新宋體", Arial, Verdana, serif;
color:#4f6b72;
font-size:12px;
line-height:150%;
}
#show{
margin:0px auto;
padding:0px;
width:200px;
height:400px
}
#header{
margin:30px auto;
}
處理的Servlet:
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import core.ChangeCharset;
import core.RC4;
public class Manage extends HttpServlet {
public Manage() {
super();
}
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
request.setCharacterEncoding("GBK"); //設置輸入編碼格式
response.setContentType("text/html;charset=GBK"); //設置輸出編碼格式
String domethod=request.getParameter("domethod");
if(domethod.equals("encrypt")){
String plain=request.getParameter("plainText");
RC4 rc4=new RC4();
String cipher=rc4.encrypt(plain);
System.out.println(cipher);
request.setAttribute("cipher", cipher);
request.getRequestDispatcher("home.jsp").forward(request, response);
}
if(domethod.equals("decipher")){
String cipher=request.getParameter("cipherText");
RC4 rc4=new RC4();
String plain=rc4.encrypt(cipher);
request.setAttribute("plain1", plain);
request.getRequestDispatcher("home.jsp").forward(request, response);
}
}
public void init() throws ServletException {
// Put your code here
}
}(中網互贏 手機客戶端)
Ⅵ 怎麼啟用 app transport security安全功能
最近看見蘋果下發的通知是關於所有iosapp都要使用滲談禪安全的https鏈接與伺服器進行通信的,並且是2017年1月1日開始執行(雖然後期另行通知是時間有所推遲),那也是早晚的事了。
蘋果要求的安全https鏈接不是在http上加一個s這么簡單,那滿足ATS我們需要做些什麼呢
①必須是蘋果信任的CA證書機構頒發的證書,不能是自簽證書。
②後台傳輸必須滿足:TLS1.2(這個很重要)
③證書必須使用SHA256或者更好的哈希演算法進行簽名。
下面上干貨,如果你的項目是Java + Tomcat/Jboss 開發的那請看下面,你要找到相應配置證書的地方在xml配置如下,其中ciphers是加密方式、sslEnabledProtocols是使用TLS協議而關閉SSL協議(因為ssl協議出現漏洞所以關閉它)。
[html] view plain
<connector port="443"
maxhttpheadersize="8192"
address="127.0.0.1"
enablelookups="false"
disableuploadtimeout="true"
acceptCount="100"
scheme="https"
secure="true"
clientAuth="false"
SSLEnabled="侍祥true"
sslEnabledProtocols="TLSv1,TLSv1.1,TLSv1.2"
ciphers="TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
TLS_ECDHE_RSA_WITH_RC4_128_SHA,
TLS_RSA_WITH_AES_128_CBC_SHA256,
TLS_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA256,
TLS_RSA_WITH_AES_256_CBC_SHA,
SSL_RSA_WITH_RC4_128_SHA"
keystoreFile="mydomain.key"
keystorePass="password"
truststoreFile="mytruststore.truststore"
truststorePass="password"/>
如果你的項目是.NET 開發的項目那你請看下面,.NET修改起來很簡單只需安裝一個程序,在 windows上 有一個很好用的軟體來解決此問題 叫 IISCrypto40.exe ,
下載完後,在windows server 伺服器上運行此軟體,然後按照上圖來勾選每一項,最後 apply後需要重啟伺服器,重啟之後就大功告成,叢塵你的https網站安全級別也被提高。
Ⅶ java.lang.NullPointerException
寫一個用戶名和留言再讀出來?檢查一下
File file=new File("D:\\mule-1.3-rc4\\新建文件夾\\1.log");
這句成功了沒?捕捉一下IOException 看看
另外
if("submit".equals(action))//這句有點棚孫問題,你想判斷喊轎提交表單的話用個form好鏈滲鏈了,不需要這么來判斷
{
File file=new File("D:\\mule-1.3-rc4\\新建文件夾\\1.log");
String name=request.getParameter("name");
String words=request.getParameter("words");
try{
DataOutputStream dataout=new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(file)
)
);
dataout.writeUTF(name);
dataout.writeUTF(words);
dataout.close();
}catch(IOException e){
}
}
//加個按鈕來submit表單
<Form>
<imput type="submit" id="submit" value="提交">
<body><div align="center">
<%
String action=request.getParameter("action");
request.setCharacterEncoding("gb2312");
if(action!=null){ //不為空的話往下做
File file=new File("D:\\mule-1.3-rc4\\新建文件夾\\1.log");
String name=request.getParameter("name");
String words=request.getParameter("words");
try{
DataOutputStream dataout=new DataOutputStream(
new BufferedOutputStream(
new FileOutputStream(file)
)
);
dataout.writeUTF(name);
dataout.writeUTF(words);
dataout.close();
}catch(IOException e){
}
}
%>
</form>
Ⅷ JAVA簡單加密解密,寫入文件再讀取解密就不行了
這個因為加密的時候使用char[]數組,輸出到文件的時蔽衫候用GBK編碼,而一些字元GBK無法編碼,因此到文件中用"?"替代了。
你可以比較一下encryptedStr與lines,雖然控制台看著是一樣,但宏悶腔不是同一個字元串,只不過亂碼字元都用"?"表罩啟示了
Ⅸ java des des3 rc4加密後字元串會增大多少
package com.*;
public class RC4 {
public static String decry_RC4(byte[] data, String key) {
if (data == null || key == null) {
return null;
}
return asString(RC4Base(data, key));
}
public static String decry_RC4(String data, String key) {
if (data == null || key == null) {
return null;
}
return new String(RC4Base(HexString2Bytes(data), key));
}
public static byte[] encry_RC4_byte(String data, String key) {
if (data == null || key == null) {
return null;
}
byte b_data[] = data.getBytes();
return RC4Base(b_data, key);
}
public static String encry_RC4_string(String data, String key) {
if (data == null || key == null) {
return null;
}
return toHexString(asString(encry_RC4_byte(data, key)));
}
private static String asString(byte[] buf) {
StringBuffer strbuf = new StringBuffer(buf.length);
for (int i = 0; i < buf.length; i++) {
strbuf.append((char) buf[i]);
}
return strbuf.toString();
}
private static byte[] initKey(String aKey) {
byte[] b_key = aKey.getBytes();
byte state[] = new byte[256];
for (int i = 0; i < 256; i++) {
state[i] = (byte) i;
}
int index1 = 0;
int index2 = 0;
if (b_key == null || b_key.length == 0) {
return null;
}
for (int i = 0; i < 256; i++) {
index2 = ((b_key[index1] & 0xff) + (state[i] & 0xff) + index2) & 0xff;
byte tmp = state[i];
state[i] = state[index2];
state[index2] = tmp;
index1 = (index1 + 1) % b_key.length;
}
return state;
}
private static String toHexString(String s) {
String str = "";
for (int i = 0; i < s.length(); i++) {
int ch = (int) s.charAt(i);
String s4 = Integer.toHexString(ch & 0xFF);
if (s4.length() == 1) {
s4 = '0' + s4;
}
str = str + s4;
}
return str;// 0x表示十六進制
}
private static byte[] HexString2Bytes(String src) {
int size = src.length();
byte[] ret = new byte[size / 2];
byte[] tmp = src.getBytes();
for (int i = 0; i < size / 2; i++) {
ret[i] = uniteBytes(tmp[i * 2], tmp[i * 2 + 1]);
}
return ret;
}
private static byte uniteBytes(byte src0, byte src1) {
char _b0 = (char) Byte.decode("0x" + new String(new byte[] { src0 })).byteValue();
_b0 = (char) (_b0 << 4);
char _b1 = (char) Byte.decode("0x" + new String(new byte[] { src1 })).byteValue();
byte ret = (byte) (_b0 ^ _b1);
return ret;
}
private static byte[] RC4Base(byte[] input, String mKkey) {
int x = 0;
int y = 0;
byte key[] = initKey(mKkey);
int xorIndex;
byte[] result = new byte[input.length];
for (int i = 0; i < input.length; i++) {
x = (x + 1) & 0xff;
y = ((key[x] & 0xff) + y) & 0xff;
byte tmp = key[x];
key[x] = key[y];
key[y] = tmp;
xorIndex = ((key[x] & 0xff) + (key[y] & 0xff)) & 0xff;
result[i] = (byte) (input[i] ^ key[xorIndex]);
}
return result;
}
public static void main(String[] args) {
String inputStr = "做個好男人";
String str = encry_RC4_string(inputStr, "123456");
System.out.println(str);
System.out.println(decry_RC4(str, "123456"));
}
}
Ⅹ 求大神用java實現RC4的加密,解密功能,高分懸賞.
importjavax.crypto.Cipher;
importjavax.crypto.spec.SecretKeySpec;
importjavax.xml.bind.DatatypeConverter;
publicclassTest{
publicstaticvoidmain(String[]args)throwsException{
Ciphercipher=Cipher.getInstance("RC4");
Stringpwd="123456";
Stringptext="HelloWorld你好";
SecretKeySpeckey=newSecretKeySpec(pwd.getBytes("UTF-8"),"RC4");
cipher.init(Cipher.ENCRYPT_MODE,key);
byte[]cdata=cipher.update(ptext.getBytes("UTF-8"));
//解密
cipher.init(Cipher.DECRYPT_MODE,key);
byte[]ddata=cipher.update(cdata);
System.out.println("密碼:"+pwd);
System.out.println("明文:"晌隱+ptext);
System.out.println("密文:"+DatatypeConverter.printHexBinary(cdata));
System.out.println("解密文:"+newString(ddata,"UTF-8"));
}
}
密碼:123456
明文:HelloWorld你鎮戚好
密文:
解密文御謹陵:HelloWorld你好
RC4已經不太安全,只能用於一般加密,不能用於金融等緊要場合。
