當前位置:首頁 » 密碼管理 » java的md5加密原理

java的md5加密原理

發布時間: 2022-07-10 17:15:49

java MD5如何解密

MD5 不能解密, MD5的破解方式就是 把不同的字元串按MD5加密 然後對比加密後的結果是不是一樣. 在線MD5解密 也是這樣的原理.

❷ java 中如何進行md5加密

JDK裡面有一個java.security.MessageDigest類,這個類就是用來加密的。

加密代碼如下:

Stringtoken=System.currentTimeMillis()+newRandom().nextInt()+"";
try{
MessageDigestmd=MessageDigest.getInstance("MD5");
byte[]md5=md.digest(token.getBytes());
}catch(Exceptione){
thrownewRuntimeException(e);
}

這個byte類型的數組就是使用MD5加密後的結果

❸ java用md5密碼加密有必要嗎

有必要的,md5就是為了防止人偷窺,而當密碼很短的時候,利用暴力搜索也比較容易搜索到,只有密碼強度足夠的情況下才有意義,你想轉換也就沒那麼容易了。md5類hash演算法的設計初衷就是單向,即不可逆。

❹ java中md5加密

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public class md5 {
public String str;

public void md5s(String plainText) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes());
byte b[] = md.digest();

int i;

StringBuffer buf = new StringBuffer("");
for (int offset = 0; offset < b.length; offset++) {
i = b[offset];
if (i < 0)
i += 256;
if (i < 16)
buf.append("0");
buf.append(Integer.toHexString(i));
}
str = buf.toString();
System.out.println("result: " + buf.toString());// 32位的加密
System.out.println("result: " + buf.toString().substring(8, 24));// 16位的加密
} catch (NoSuchAlgorithmException e) {
// TODO Auto-generated catch block
e.printStackTrace();

}
}

public static void main(String agrs[]) {
md5 md51 = new md5();
md51.md5s("4");//加密4
}

}

❺ java演算法 md5加密方法

根據MD5演算法的特點,我們可以把MD5加密過程看作是一個函數調用過程,建議必須做如下方式修改,這樣可以保證一定程度上你的網站用戶和數據安全:
1、修改MD5演算法中的4個常數,這是最捷徑的作法,其特點是加密後的數據和加密前非常類似,但是不會被破解
2、多次加密,對MD5加密過的數據進行二次或三次加密,或者在每次加密後從重抽取部分值進行在加密,比如「我愛你」,加密後「」,我們可以取任意一部分進行再加密,比如取前18位「1E6986ACEC7BAE541」進行再加密得到「」,這種做法修改很簡單,比如asp中調用是md5("password")那麼你可以改成md5(left(md5("password"),16)),這樣以來就很安全了,就是你的數據被下載,破解的話也是不可能的
3、仿MD5加密,顧名思義,我們不採用MD5加密,而採用其他演算法,然後取其中的部分散列,比如用SHA1或SHA64得到加密結果,然後取其中的32位或16位,很像MD5演算法加密的結果,可以保證不被破解
方法有很多,我這里只是拋磚引玉,希望你在做網站的時候自己修改,可以確保萬無一失,不管你用的是什麼軟體,希望大家謹慎一下,我們把這種改法稱為MD5的私有演算法或私有MD5演算法。

❻ 誰可以告訴我md5加密原理

2004年,已經被山東大學的王小雲教授破解了。

以下是她在國際密碼學會上發表的破解原理論文。
Collisions for Hash Functions
Collisions for Hash Functions
MD4, MD5, HAVAL-128 and RIPEMD
Xiaoyun Wang1, Dengguo Feng2, Xuejia Lai3, Hongbo Yu1
The School of Mathematics and System Science, Shandong University, Jinan250100, China1
Institute of Software, Chinese Academy of Sciences, Beijing100080, China2
Dept. of Computer Science and Engineering, Shanghai Jiaotong University, Shanghai, China3
[email protected]
revised on August 17, 2004

1 Collisions for MD5
MD5 is the hash function designed by Ron Rivest [9] as a strengthened version of MD4 [8]. In 1993 Bert den
Boer and Antoon Bosselaers [1] found pseudo-collision for MD5 which is made of the same message with two
different sets of initial value. H. Dobbertin[3] found a free-start collision which consists of two different 512-bit
messages with a chosen initial value 0 V I .
ED BA x C B F x C B AC x A V I 763 4 0 D , 97 62 5 0 , 341042 3 0x B , 2375 12 0 : 0 0 0 0 0
Our attack can find many real collisions which are composed of two 1024-bit messages with the original
initial value 0 IV of MD5:
10325476 0 , 98 0 , 89 0 67452301 0 : 0 0 0 0 0 x D badcfe x C xefcdab ,B x A IV
) 0 , 2 ,..., 2 ,..., 2 , 0 , 0 , 0 , 0 ( , 31 15 31
1 1 C C M M
) 0 , 2 ,..., 2 ,..., 2 , 0 , 0 , 0 , 0 ( , 31 15 31
2 2 C C N N i i
(non-zeros at position 4,11 and 14)
such that
) , ( 5 ) , ( 5 i i N M MD N M MD .
On IBM P690, it takes about one hour to find such M and M , after that, it takes only 15 seconds to 5
minutes to find i N and i N , so that ) , ( i N M and ) , ( i N M will proce the same hash same value. Moreover,
our attack works for any given initial value.
The following are two pairs of 1024-bit messages procing collisions, the two examples have the same 1-st
half 512 bits.
M
2dd31d1 c4eee6c5 69a3d69 5cf9af98 87b5ca2f ab7e4612 3e580440 897ffbb8
634ad55 2b3f409 8388e483 5a417125 e8255108 9fc9cdf7 f2bd1dd9 5b3c3780
X1
N1
d11d0b96 9c7b41dc f497d8e4 d555655a c79a7335 cfdebf0 66f12930 8fb109d1
797f2775 eb5cd530 baade822 5c15cc79 ddcb74ed 6dd3c55f d80a9bb1 e3a7cc35
M0
2dd31d1 c4eee6c5 69a3d69 5cf9af98 7b5ca2f ab7e4612 3e580440 897ffbb8
634ad55 2b3f409 8388e483 5a41f125 e8255108 9fc9cdf7 72bd1dd9 5b3c3780
X1
N1
d11d0b96 9c7b41dc f497d8e4 d555655a 479a7335 cfdebf0 66f12930 8fb109d1
797f2775 eb5cd530 baade822 5c154c79 ddcb74ed 6dd3c55f 580a9bb1 e3a7cc35
H 9603161f f41fc7ef 9f65ffbc a30f9dbf
M
2dd31d1 c4eee6c5 69a3d69 5cf9af98 87b5ca2f ab7e4612 3e580440 897ffbb8
634ad55 2b3f409 8388e483 5a417125 e8255108 9fc9cdf7 f2bd1dd9 5b3c3780
X2
N2
313e82d8 5b8f3456 d4ac6dae c619c936 b4e253dd fd03da87 6633902 a0cd48d2
42339fe9 e87e570f 70b654ce 1e0da880 bc2198c6 9383a8b6 2b65f996 702af76f
M0
2dd31d1 c4eee6c5 69a3d69 5cf9af98 7b5ca2f ab7e4612 3e580440 897ffbb8
634ad55 2b3f409 8388e483 5a41f125 e8255108 9fc9cdf7 72bd1dd9 5b3c3780

313e82d8 5b8f3456 d4ac6dae c619c936 34e253dd fd03da87 6633902 a0cd48d2
42339fe9 e87e570f 70b654ce 1e0d2880 bc2198c6 9383a8b6 ab65f996 702af76f
H 8d5e7019 6324c015 715d6b58 61804e08
Table 1 Two pairs of collisions for MD5
2 Collisions for HAVAL-128
HAVAL is proposed in [10]. HAVAL is a hashing algorithm that can compress messages of any length in 3,4
or 5 passes and proce a fingerprint of length 128, 160, 192 or 224 bits.
Attack on a reced version for HAVAL was given by P. R. Kasselman and W T Penzhorn [7], which
consists of last rounds for HAVAL-128. We break the full HAVAL-128 with only about the 26 HAVAL
computations. Here we give two examples of collisions of HAVAL-128, where
) 0 ,..., 0 , 2 ,.... 2 , 0 , 0 , 0 , 2 ( , 8 12 1 i i i C C M M
with non-zeros at position 0,11,18, and 31 ,... 2 , 1 , 0 i , such that ) ( ) ( M HAVAL M HAVAL .
M1
6377448b d9e59f18 f2aa3cbb d6cb92ba ee544a44 879fa576 1ca34633 76ca5d4f
a67a8a42 8d3adc8b b6e3d814 5630998d 86ea5dcd a739ae7b 54fd8e32 acbb2b36
38183c9a b67a9289 c47299b2 27039ee5 dd555e14 839018d8 aabbd9c9 d78fc632
fff4b3a7 40000096 7f466aac fffffbc0 5f4016d2 5f4016d0 12e2b0 f4307f87
M1
6377488b d9e59f18 f2aa3cbb d6cb92ba ee544a44 879fa576 1ca34633 76ca5d4f
a67a8a42 8d3adc8b b6e3d814 d630998d 86ea5dcd a739ae7b 54fd8e32 acbb2b36
38183c9a b67a9289 c47299ba 27039ee5 dd555e14 839018d8 aabbd9c9 d78fc632
fff4b3a7 40000096 7f466aac fffffbc0 5f4016d2 5f4016d0 12e2b0 f4307f87
H 95b5621c ca62817a a48dacd8 6d2b54bf
M2
6377448b d9e59f18 f2aa3cbb d6cb92ba ee544a44 879fa576 1ca34633 76ca5d4f
a67a8a42 8d3adc8b b6e3d814 5630998d 86ea5dcd a739ae7b 54fd8e32 acbb2b36
38183c9a b67a9289 c47299b2 27039ee5 dd555e14 839018d8 aabbd9c9 d78fc632
fff4b3a7 40000096 7f466aac fffffbc0 5f4016d2 5f4016d0 12e2b0 f5b16963

6377488b d9e59f18 f2aa3cbb d6cb92ba ee544a44 879fa576 1ca34633 76ca5d4f
a67a8a42 8d3adc8b b6e3d814 d630998d 86ea5dcd a739ae7b 54fd8e32 acbb2b36
38183c9a b67a9289 c47299ba 27039ee5 dd555e14 839018d8 aabbd9c9 d78fc632
fff4b3a7 40000096 7f466aac fffffbc0 5f4016d2 5f4016d0 12e2b0 f5b16963
H b0e99492 d64eb647 5149ef30 4293733c
Table 2 Two pairs of collision, where i=11 and these two examples differ only at the last word
3 Collisions for MD4
MD4 is designed by R. L. Rivest[8] . Attack of H. Dobbertin in Eurocrypto'96[2] can find collision with
probability 1/222. Our attack can find collision with hand calculation, such that
) 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 2 , 2 , 0 ( , 16 31 28 31 C C M M
and ) ( 4 ) ( 4 M MD M MD .
M1
4d7a9c83 56cb927a b9d5a578 57a7a5ee de748a3c dcc366b3 b683a020 3b2a5d9f
c69d71b3 f9e99198 d79f805e a63bb2e8 45dd8e31 97e31fe5 2794bf08 b9e8c3e9
M1
4d7a9c83 d6cb927a 29d5a578 57a7a5ee de748a3c dcc366b3 b683a020 3b2a5d9f
c69d71b3 f9e99198 d79f805e a63bb2e8 45dc8e31 97e31fe5 2794bf08 b9e8c3e9
H 5f5c1a0d 71b36046 1b5435da 9b0d807a
M2
4d7a9c83 56cb927a b9d5a578 57a7a5ee de748a3c dcc366b3 b683a020 3b2a5d9f
c69d71b3 f9e99198 d79f805e a63bb2e8 45dd8e31 97e31fe5 f713c240 a7b8cf69

4d7a9c83 d6cb927a 29d5a578 57a7a5ee de748a3c dcc366b3 b683a020 3b2a5d9f
c69d71b3 f9e99198 d79f805e a63bb2e8 45dc8e31 97e31fe5 f713c240 a7b8cf69
H e0f76122 c429c56c ebb5e256 b809793
Table 3 Two pairs of collisions for MD4
4 Collisions for RIPEMD
RIPEMD was developed for the RIPE project (RACE Integrrity Primitives Evalustion, 1988-1992). In
1995, H. Dobbertin proved that the reced version RIPEMD with two rounds is not collision-free[4]. We show
that the full RIPEMD also isnOt collision-free. The following are two pairs of collisions for RIPEMD:
) 2 , 0 , 0 , 0 , 0 , 2 2 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 ( , 31 31 18 20 ' C C M M i i
M1
579faf8e 9ecf579 574a6aba 78413511 a2b410a4 ad2f6c9f b56202c 4d757911
bdeaae7 78bc91f2 47bc6d7d 9abdd1b1 a45d2015 817104ff 264758a8 61064ea5
M1
579faf8e 9ecf579 574a6aba 78513511 a2b410a4 ad2f6c9f b56202c 4d757911
bdeaae7 78bc91f2 c7c06d7d 9abdd1b1 a45d2015 817104ff 264758a8 e1064ea5
H 1fab152 1654a31b 7a33776a 9e968ba7
M2
579faf8e 9ecf579 574a6aba 78413511 a2b410a4 ad2f6c9f b56202c 4d757911
bdeaae7 78bc91f2 47bc6d7d 9abdd1b1 a45d2015 a0a504ff b18d58a8 e70c66b6

579faf8e 9ecf579 574a6aba 78513511 a2b410a4 ad2f6c9f b56202c 4d757911
bdeaae7 78bc91f2 c7c06d7d 9abdd1b1 a45d2015 a0a504ff b18d58a8 670c66b6
H 1f2c159f 569b31a6 dfcaa51a 25665d24
Table 4 The collisions for RIPEMD
5 Remark
Besides the above hash functions we break, there are some other hash functions not having ideal security. For
example, collision of SHA-0 [6] can be found with about 240 computations of SHA-0 algorithms, and a collision
for HAVAL-160 can be found with probability 1/232.
Note that the messages and all other values in this paper are composed of 32-bit words, in each 32-bit word
the most left byte is the most significant byte.
1 B. den Boer, Antoon Bosselaers, Collisions for the Compression Function of MD5, Eurocrypto,93.
2 H. Dobbertin, Cryptanalysis of MD4, Fast Software Encryption, LNCS 1039, D. , Springer-Verlag, 1996.
3 H. Dobbertin, Cryptanalysis of MD5 compress, presented at the rump session of EurocrZpt'96.
4 Hans Dobbertin, RIPEMD with Two-round Compress Function is Not Collision-Free, J. Cryptology 10(1),
1997.
5 H. Dobbertin, A. Bosselaers, B. Preneel, "RIPMEMD-160: A Strengthened Version of RIPMMD," Fast
Software EncrZption, LNCS 1039, D.Gollmann, Ed., Springer-Verlag, 1996, pp. 71-82.
6 FIPS 180-1, Secure hash standard, NIST, US Department of Commerce, Washington D. C., April 1995.
7 P. R. Kasselman, W T Penzhorn , Cryptananlysis od reced version of HAVAL, Vol. 36, No. 1, Electronic
Letters, 2000.
8 R. L. Rivest, The MD4 Message Digest Algorithm, Request for Comments (RFC)1320, Internet Activities
Board, Internet Privacy Task Force, April 1992.
9 R. L Rivest, The MD5 Message Digest Algorithm, Request for Comments (RFC)1321, Internet Activities
Board, Internet PrivacZ Task Force, April 1992.3RIPEMD-1281
10 Y. Zheng, J. Pieprzyk, J. Seberry, HAVAL--A One-way Hashing Algorithm with Variable Length of Output,
Auscrypto'92.

❼ java MD5加密,解釋解釋!

給你解釋一下for裡面這段代碼
byte byte0 = md[i];//取得md數組中第i個元素

str[k++] = hexDigits[byte0 >>> 4 & 0xf ];取得byte0的前四位,然後找到轉化成16進制字元,如果byte0為10001000(二進制)那麼前四位就是1000,十進制就是8,而 hexDigits[8]就=『8』
str[k++] = hexDigits[byte0 & 0xf ]; //同理取得byte0的後四位,轉化成16進制字元。

❽ 如何在java中實現md5加密和解密

package endecrypt;
02.
03.import java.io.UnsupportedEncodingException;
04.import java.security.MessageDigest;
05.import java.security.NoSuchAlgorithmException;
06.
07./**
08. * 採用MD5加密解密
09. * @author tfq
10. * @datetime 2011-10-13
11. */
12.public class MD5Util {
13.
14. /***
15. * MD5加碼 生成32位md5碼
16. */
17. public static String string2MD5(String inStr){
18. MessageDigest md5 = null;
19. try{
20. md5 = MessageDigest.getInstance("MD5");
21. }catch (Exception e){
22. System.out.println(e.toString());
23. e.printStackTrace();
24. return "";
25. }
26. char[] charArray = inStr.toCharArray();
27. byte[] byteArray = new byte[charArray.length];
28.
29. for (int i = 0; i < charArray.length; i++)
30. byteArray[i] = (byte) charArray[i];
31. byte[] md5Bytes = md5.digest(byteArray);
32. StringBuffer hexValue = new StringBuffer();
33. for (int i = 0; i < md5Bytes.length; i++){
34. int val = ((int) md5Bytes[i]) & 0xff;
35. if (val < 16)
36. hexValue.append("0");
37. hexValue.append(Integer.toHexString(val));
38. }
39. return hexValue.toString();
40.
41. }
42.
43. /**
44. * 加密解密演算法 執行一次加密,兩次解密
45. */
46. public static String convertMD5(String inStr){
47.
48. char[] a = inStr.toCharArray();
49. for (int i = 0; i < a.length; i++){
50. a[i] = (char) (a[i] ^ 't');
51. }
52. String s = new String(a);
53. return s;
54.
55. }

❾ MD5的加密原理

http://www.mmkey.com/md5/

這個,還有運氣的成分再裡面,你看看吧

熱點內容
4k無壓縮 發布:2025-05-15 06:02:54 瀏覽:73
hp存儲6350 發布:2025-05-15 05:40:41 瀏覽:233
怎麼更改電腦默認緩存位置 發布:2025-05-15 05:39:01 瀏覽:877
安卓qq公孫離在哪個戰區戰力最低 發布:2025-05-15 05:38:58 瀏覽:493
androidffmpeg壓縮 發布:2025-05-15 05:37:02 瀏覽:288
ftp簡稱是 發布:2025-05-15 05:37:02 瀏覽:121
光遇發光耳機怎麼設置安卓 發布:2025-05-15 05:32:03 瀏覽:113
台電安卓平板系統太低怎麼辦 發布:2025-05-15 05:20:00 瀏覽:509
安裝了zlib編譯報錯 發布:2025-05-15 05:19:56 瀏覽:168
二分演算法無序 發布:2025-05-15 05:18:22 瀏覽:30