導航:首頁 > 文檔加密 > hexstring加密

hexstring加密

發布時間:2025-01-10 15:50:49

java代碼想加密怎麼處理

如果你說的是文本加密,有很多方法,自己也可以寫個字元變換程序

如果是代碼加密,沒用的,java就是開源。
你藏再厲害,編譯+反編譯,干凈的源碼就出來了

㈡ java String gbk編碼和c# String gbk 編碼難道不一樣

您好,提問者:
確實是不一樣的,這個時候給你一種也可用於.net對接的加密:

/**
*加密方法
*@paramstr
*@return
*/
publicstaticStringencode(Stringstr){
//根據默認編乎賣碼獲取位元組數組
byte[]bytes=str.getBytes();
StringBuildersb=newStringBuilder(bytes.length*2);
//將位元組數組中每個位元組拆解成2位16進制整數
for(inti=0;i<bytes.length;i++){
sb.append(hexString.charAt((bytes[i]&0xf0)>>4));
sb.append(hexString.charAt((bytes[i]&0x0f)>>0));
}
returnsb.toString();
}

/**
*得到16進制的GBK編碼,轉換為漢字
*@paramhexStr
*@return
*/
publicstaticStringdecode(StringhexStr){
if(null==hexStr||"".equals(hexStr)||(hexStr.length())%2!=0){
returnnull;
}
intbyteLength=hexStr.length()/2;
byte[]bytes=newbyte[byteLength];
inttemp=0;
for(inti=0;i<byteLength;i++){
temp=hex2Dec(hexStr.charAt(2*i))*16+hex2Dec(hexStr.charAt(2*i+1));
bytes[i]=(byte)(temp<128?temp:temp-256);
}
returnnewString(bytes);
}
privatestaticStringhexString="0123456789ABCDEF";
privatestaticinthex2Dec(charch){
if(ch=='0')
return0;
if(ch=='1')
return1;
if(ch=='2')
return2;
if(ch=='3')
return3;
if(ch=='4')
return4;
if(ch=='5')
return5;
if(ch=='6')
return6;
if(ch=='7')
return7;
if(ch=='8')
return8;
if(ch=='9')
return9;
if(ch=='a')
return10;
if(ch=='A')
return10;
if(ch=='B')
return11;
if(ch=='b')
return11;
if(ch=='C'滾納)
return12;
if(ch=='c')
return12;
if(ch=='D')
return13;
if(ch=='d')
return13;
if(ch=='E'歲備逗)
return14;
if(ch=='e')
return14;
if(ch=='F')
return15;
if(ch=='f')
return15;
elsereturn-1;
}

㈢ 設計一種很難被破解的異或加密方法

不會哦。比如我有一個大小為1000位元組的文本文件,我先產生了4個隨機數,100,4,200,5
然後先取文件100位元組處的數據然後與下一個位元組也就是101位置的數據異或,然後取加密後的數據繼續與下個位元組XOR,到文件尾後轉到文件頭繼續,直到完全把整個文件異或加密4遍,也就是4000次XOR,同樣再取文件200位元組偏移處數據進行5000次XOR,解密者只需知道4個隨機數然後按步驟反過來XOR就還原為原文本文件,我想知道不知道4個隨機數的情況下怎樣破解,窮舉嗎,難度大不大,有什麼更好的異或加密方案,如用一張jpg照

㈣ java md5加密 index頁面代碼


/**
*將指定byte數組轉換成16進制字元串
*@paramb
*@return
*/
(byte[]b){
StringBufferhexString=newStringBuffer();
for(inti=0;i<b.length;i++){
Stringhex=Integer.toHexString(b[i]&0xFF);
if(hex.length()==1){
hex='0'+hex;
}
hexString.append(hex.toUpperCase());
}
returnhexString.toString();
}

/**
*獲得加密後的16進制形式口令
*@parampassword
*@return
*@
*@
*/
(Stringpassword)
,UnsupportedEncodingException{
//聲明加密後的口令數組變數
byte[]pwd=null;
//隨機數生成器
SecureRandomrandom=newSecureRandom();
//聲明鹽數組變數
byte[]salt=newbyte[SALT_LENGTH];
//將隨機數放入鹽變數中
random.nextBytes(salt);

//聲明消息摘要對象
MessageDigestmd=null;
//創建消息摘要
md=MessageDigest.getInstance("MD5");
//將鹽數據傳入消息摘要對象
md.update(salt);
//將口令的數據傳給消息摘要對象
md.update(password.getBytes("UTF-8"));
//獲得消息摘要的位元組數組
byte[]digest=md.digest();

//因為要在口令的位元組數組中存放鹽,所以加上鹽的位元組長度
pwd=newbyte[digest.length+SALT_LENGTH];
//將鹽的位元組拷貝到生成的加密口令位元組數組的前12個位元組,以便在驗證口令時取出鹽
System.array(salt,0,pwd,0,SALT_LENGTH);
//將消息摘要拷貝到加密口令位元組數組從第13個位元組開始的位元組
System.array(digest,0,pwd,SALT_LENGTH,digest.length);
//將位元組數組格式加密後的口令轉化為16進制字元串格式的口令
returnbyteToHexString(pwd);
}

publicstaticvoidmain(String[]args){//測試方法
try{
System.out.println(getEncryptedPwd("123456"));
}catch(NoSuchAlgorithmExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}catch(UnsupportedEncodingExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
}

在jsp頁面中可以調用getEncryptedPwd方法

㈤ DES加密演算法CBC模式怎麼解密最好有程序 謝謝~(*^__^*)

原型:
int WINAPI icePub_desEncryptionHex(char *strInputHexstring, char *strOutputHexstring, char *strKeyHexstring)
輸入:strInputHexstring 待加密16進制數據串,16位元組長度
strKeyHexstring 單des密鑰16進制串,16位元組長度
輸出:strOutputHexstring 加密後16進制數據串,16位元組長度

原型:
int WINAPI icePub_desDecryptionHex(char *strInputHexstring, char *strOutputHexstring, char *strKeyHexstring)
輸入:strInputHexstring 待解密16進制數據串,16位元組長度
strKeyHexstring 單des密鑰16進制串,16位元組長度
輸出:strOutputHexstring 解密後16進制數據串,16位元組長度

閱讀全文

與hexstring加密相關的資料

熱點內容
程序員越來越困 瀏覽:865
女朋友java程序員 瀏覽:338
魔獸世界加密貨幣 瀏覽:783
程序員打卡日記 瀏覽:766
車間壓縮空氣有水怎麼處理 瀏覽:835
java類調用php 瀏覽:476
php時間控制 瀏覽:807
用流程圖表示演算法分類 瀏覽:931
本地git文件夾誤刪除怎麼恢復 瀏覽:748
java快速開發平台開源 瀏覽:996
java實戰從入門 瀏覽:155
javahello程序 瀏覽:13
java系統輸出 瀏覽:934
430單片機存儲 瀏覽:396
私人雲php源碼 瀏覽:449
解壓系統內核 瀏覽:802
java精確兩位小數 瀏覽:839
安卓系統如何看游戲幀數 瀏覽:435
生產節拍模擬app哪個好用 瀏覽:439
光遇安卓渠道怎麼轉 瀏覽:422