2017-08-31 86 views
1

我試圖解密十六進制編碼字符串通過Blowfish。但結果與正確的結果不同。Blowfish解密十六進制編碼字符串

String s="a1d0534e4baf9e670bde8670caee8b87" 
String decKey = "R=U!LH$O2B#"; 
Cipher m_decrypt = Cipher.getInstance("Blowfish/ECB/PKCS5Padding"); 
m_decrypt.init(Cipher.DECRYPT_MODE, new SecretKeySpec(decKey.getBytes(),"Blowfish")); 
byte[] decrypted = m_decrypt.doFinal(Hex.decodeHex(s.toCharArray())); 

從站點正確的結果:C6 B7 8D 52 31 35 30 34 31 38 38 36 39 37 02 02

我的結果:-58 -73 -115 82 49 53 48 52 49 56 56 54 57 55

我檢查與礦正確的字節陣列在此網站http://blowfish.online-domain-tools.com/

+0

謝謝,我會修復帖子名稱。 – Mike

+0

Blowfish已經過了它的「最好使用」日期,甚至它的作者也不再使用它了。 – zaph

+1

是「我的結果」十進制和「正確的結果從站點」十六進制?這些是不同的編碼,相同數據的不同編碼將有所不同。正確結果的最後一個「02 02」是通常透明地移除的兩個填充字節。 – zaph

回答

2

的correect結果:c6 b7 8d 52 31 35 30 34 31 38 38 36 39 37 02 02
是十六進制編碼,幷包含填充的兩個字節。

我的結果:-58 -73 -115 82 49 53 48 52 49 56 56 54 57 55
in帶符號的十進制編碼,沒有填充字節。

它們只是在不同的編碼中具有相同的值,其中「我的結果」像往常一樣去除了填充。

相關問題