MD5
什么是破解?
已知A,通过MD5计算后得出AB, 那么破解的过程就是能够找到一种方法使得通过AB能够得到原始的A。比如说有没有可能找到MD5的逆过程, 通过这个MD5逆过程反向找到原始的A?
那么MD5能破解吗?
不能的, MD5是单向的, 根本就没有这样一个可逆的过程!
所谓MD5破解
目前网上充斥着各种所谓的MD5破解方法, 那根本就不是什么破解, 整理出来基本都是个“猜”。这里整理了下网上所谓的MD5破解大发:
1、猜
2、暴力破解
3、查字典, 彩虹表
4、这里不想将山大王小云教授这种方式列在此处
王小云教授的这种方法也是一种可能的方式, 但也并没有破解出MD5。附件中留有相关论文。
除此之外好像听说某视频网站公司声称真的破解了MD5, 如果不是瞎扯蛋, 能把具体破解算法公布出来吗? 这不应该是什么机密吧。
MD5
MD5中的几个变换函数
初始化MD Buffer
// state of this object private int[] state;
state = new int[4];
void implReset() { // Load magic initialization constants. state[0] = 0x67452301; state[1] = 0xefcdab89; state[2] = 0x98badcfe; state[3] = 0x10325476; }
private static int A = 0x67452301; private static int B = 0xefcdab89; private static int C = 0x98badcfe; private static int D = 0x10325476;
四个辅助函数:
F(X,Y,Z) = XY v not(X) Z
G(X,Y,Z) = XZ v Y not(Z)
H(X,Y,Z) = X xor Y xor Z
I(X,Y,Z) = Y xor (X v not(Z))
// F(X,Y,Z) = XY v not(X) Z // #define F(x, y, z) (((x) & (y)) | ((~x) & (z))) private static int F(int x, int y, int z) { return (((x) & (y)) | ((~x) & (z))); } // G(X,Y,Z) = XZ v Y not(Z) // #define G(x, y, z) (((x) & (z)) | ((y) & (~z))) private static int G(int x, int y, int z) { return (((x) & (z)) | ((y) & (~z))); } // H(X,Y,Z) = X xor Y xor Z // #define H(x, y, z) ((x) ^ (y) ^ (z)) private static int H(int x, int y, int z) { return ((x) ^ (y) ^ (z)); } // I(X,Y,Z) = Y xor (X v not(Z)) // #define I(x, y, z) ((y) ^ ((x) | (~z))) private static int I(int x, int y, int z) { return ((y) ^ ((x) | (~z))); } // #define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) private static int rotateLeft(int x, int n) { return (((x) << (n)) | ((x) >> (32-(n)))); } // #define FF(a, b, c, d, x, s, ac) { \ // (a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int FF(int a, int b, int c, int d, int x, int s, int ac) { a += F(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; } // #define GG(a, b, c, d, x, s, ac) { \ // (a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int GG(int a, int b, int c, int d, int x, int s, int ac) { a += G(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; } // #define HH(a, b, c, d, x, s, ac) { \ // (a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int HH(int a, int b, int c, int d, int x, int s, int ac) { a += H(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; } // #define II(a, b, c, d, x, s, ac) { \ // (a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \ // (a) = ROTATE_LEFT ((a), (s)); \ // (a) += (b); \ // } private static int II(int a, int b, int c, int d, int x, int s, int ac) { a += I(b, c, d) + x + ac; a = rotateLeft(a, s); a += b; return a; }
Java中MD5的实现代码在sun.security.provider.MD5中。
Provider: sun.security.provider.Sun
但里边的方法都不对外开放, 不能直接访问。
private static final char[] HEX_CHAR = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'};; @Test public void md5() { String message = "13120084002"; MessageDigest md5 = null; try { md5 = MessageDigest.getInstance("MD5"); } catch (NoSuchAlgorithmException e) { Assert.fail(e.getMessage()); } byte[] digest = md5.digest(message.getBytes()); Assert.assertNotNull(digest); Assert.assertEquals(16, digest.length); // length of digest must be 16: 128bits StringBuilder sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { byte j = digest[i]; int h = j >> 4 & 0x0f; int l = j & 0x0f; sb.append(Integer.toHexString(h)); sb.append(Integer.toHexString(l)); } String result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { sb.append(String.format("%02x", new Integer(digest[i] & 0xff))); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { int j = digest[i]; if(digest[i] < 0) { j = 256 + digest[i]; } sb.append(HEX_CHAR[j / 16]); sb.append(HEX_CHAR[j % 16]); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); result = Base64.byteArrayToBase64(digest); System.out.println(message + "(base64:" + result + ")"); }
13120084002(hex:4dccd5cf34d388df98643f66866366b1) 13120084002(hex:4dccd5cf34d388df98643f66866366b1) 13120084002(hex:4dccd5cf34d388df98643f66866366b1) 13120084002(base64:TczVzzTTiN+YZD9mhmNmsQ==)
The MD5 Message-Digest Algorithm, https://tools.ietf.org/html/rfc1321
The MD4 Message-Digest Algorithm, https://tools.ietf.org/html/rfc1320
The MD4 Message Digest Algorithm, https://tools.ietf.org/html/rfc1186
The MD2 Message-Digest Algorithm, https://tools.ietf.org/html/rfc1319
SHA
Java中US Secure Hash Algorithm 1 (SHA1)实现:
sun.security.provider.SHA
Java中没提供SHA-224实现。
Java中Secure Hash Algorithm SHA-256实现:
sun.security.provider.SHA2
Java中Secure Hash Algorithm SHA-384 and SHA-512实现:
sun.security.provider.SHA5
其中SHA-384实现sun.security.provider.SHA5.SHA384,SHA-512实现sun.security.provider.SHA5.SHA512
SHA1
f(t;B,C,D) = (B AND C) OR ((NOT B) AND D) ( 0 <= t <= 19)
f(t;B,C,D) = B XOR C XOR D (20 <= t <= 39)
f(t;B,C,D) = (B AND C) OR (B AND D) OR (C AND D) (40 <= t <= 59)
f(t;B,C,D) = B XOR C XOR D (60 <= t <= 79)
SHA-224 and SHA-256
CH( x, y, z) = (x AND y) XOR ( (NOT x) AND z)
MAJ( x, y, z) = (x AND y) XOR (x AND z) XOR (y AND z)
BSIG0(x) = ROTR^2(x) XOR ROTR^13(x) XOR ROTR^22(x)
BSIG1(x) = ROTR^6(x) XOR ROTR^11(x) XOR ROTR^25(x)
SSIG0(x) = ROTR^7(x) XOR ROTR^18(x) XOR SHR^3(x)
SSIG1(x) = ROTR^17(x) XOR ROTR^19(x) XOR SHR^10(x)
SHA-384 and SHA-512
CH( x, y, z) = (x AND y) XOR ( (NOT x) AND z)
MAJ( x, y, z) = (x AND y) XOR (x AND z) XOR (y AND z)
BSIG0(x) = ROTR^28(x) XOR ROTR^34(x) XOR ROTR^39(x)
BSIG1(x) = ROTR^14(x) XOR ROTR^18(x) XOR ROTR^41(x)
SSIG0(x) = ROTR^1(x) XOR ROTR^8(x) XOR SHR^7(x)
SSIG1(x) = ROTR^19(x) XOR ROTR^61(x) XOR SHR^6(x)
Java中US Secure Hash Algorithm 1 (SHA1)实例:
@Test public void sha1() { String message = "13120084002"; MessageDigest sha1 = null; try { sha1 = MessageDigest.getInstance("SHA1"); } catch (NoSuchAlgorithmException e) { Assert.fail(e.getMessage()); } byte[] digest = sha1.digest(message.getBytes()); Assert.assertNotNull(digest); Assert.assertEquals(20, digest.length); // length of digest must be 20: 160bits StringBuilder sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { byte j = digest[i]; int h = j >> 4 & 0x0f; int l = j & 0x0f; sb.append(Integer.toHexString(h)); sb.append(Integer.toHexString(l)); } String result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { sb.append(String.format("%02x", new Integer(digest[i] & 0xff))); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { int j = digest[i]; if(digest[i] < 0) { j = 256 + digest[i]; } sb.append(HEX_CHAR[j / 16]); sb.append(HEX_CHAR[j % 16]); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); result = Base64.byteArrayToBase64(digest); System.out.println(message + "(base64:" + result + ")"); }
Java中Secure Hash Algorithm SHA-256实例:
@Test public void sha256() { String message = "13120084002"; MessageDigest sha256 = null; try { sha256 = MessageDigest.getInstance("SHA-256"); } catch (NoSuchAlgorithmException e) { Assert.fail(e.getMessage()); } byte[] digest = sha256.digest(message.getBytes()); Assert.assertNotNull(digest); Assert.assertEquals(32, digest.length); // length of digest must be 32: 256bits StringBuilder sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { byte j = digest[i]; int h = j >> 4 & 0x0f; int l = j & 0x0f; sb.append(Integer.toHexString(h)); sb.append(Integer.toHexString(l)); } String result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { sb.append(String.format("%02x", new Integer(digest[i] & 0xff))); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { int j = digest[i]; if(digest[i] < 0) { j = 256 + digest[i]; } sb.append(HEX_CHAR[j / 16]); sb.append(HEX_CHAR[j % 16]); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); result = Base64.byteArrayToBase64(digest); System.out.println(message + "(base64:" + result + ")"); }
Java中Secure Hash Algorithm SHA-384实例:
@Test public void sha384() { String message = "13120084002"; MessageDigest sha384 = null; try { sha384 = MessageDigest.getInstance("SHA-384"); } catch (NoSuchAlgorithmException e) { Assert.fail(e.getMessage()); } byte[] digest = sha384.digest(message.getBytes()); Assert.assertNotNull(digest); Assert.assertEquals(48, digest.length); // length of digest must be 48: 384bits StringBuilder sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { byte j = digest[i]; int h = j >> 4 & 0x0f; int l = j & 0x0f; sb.append(Integer.toHexString(h)); sb.append(Integer.toHexString(l)); } String result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { sb.append(String.format("%02x", new Integer(digest[i] & 0xff))); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { int j = digest[i]; if(digest[i] < 0) { j = 256 + digest[i]; } sb.append(HEX_CHAR[j / 16]); sb.append(HEX_CHAR[j % 16]); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); result = Base64.byteArrayToBase64(digest); System.out.println(message + "(base64:" + result + ")"); }
Java中Secure Hash Algorithm SHA-512实例:
@Test public void sha512() { String message = "13120084002"; MessageDigest sha512 = null; try { sha512 = MessageDigest.getInstance("SHA-512"); } catch (NoSuchAlgorithmException e) { Assert.fail(e.getMessage()); } byte[] digest = sha512.digest(message.getBytes()); Assert.assertNotNull(digest); Assert.assertEquals(64, digest.length); // length of digest must be 64: 512bits StringBuilder sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { byte j = digest[i]; int h = j >> 4 & 0x0f; int l = j & 0x0f; sb.append(Integer.toHexString(h)); sb.append(Integer.toHexString(l)); } String result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { sb.append(String.format("%02x", new Integer(digest[i] & 0xff))); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); sb = new StringBuilder(32); for (int i = 0; i < digest.length; i++) { int j = digest[i]; if(digest[i] < 0) { j = 256 + digest[i]; } sb.append(HEX_CHAR[j / 16]); sb.append(HEX_CHAR[j % 16]); } result = sb.toString(); System.out.println(message + "(hex:" + result + ")"); result = Base64.byteArrayToBase64(digest); System.out.println(message + "(base64:" + result + ")"); }
Using HMAC-SHA-256, HMAC-SHA-384, and HMAC-SHA-512 with IPsec, https://tools.ietf.org/html/rfc4868
A 224-bit One-way Hash Function: SHA-224, https://tools.ietf.org/html/rfc3874
US Secure Hash Algorithms (SHA and SHA-based HMAC and HKDF), https://tools.ietf.org/html/rfc6234
US Secure Hash Algorithms (SHA and HMAC-SHA), https://tools.ietf.org/html/rfc4634
US Secure Hash Algorithm 1 (SHA1), https://tools.ietf.org/html/rfc3174
相关推荐
MD5(Message-Digest Algorithm 5)和SHA(Secure Hash Algorithm)是一类广泛使用的哈希函数,它们能为任意大小的文件生成一个固定长度的摘要,这个摘要就像是文件的“数字指纹”。在本资料包“文件唯一性检测MD5 &...
MD5和SHA-1是两种广泛使用的哈希函数,在信息技术领域,它们主要用于数据完整性和校验。这些工具在软件下载、文件传输、数字签名以及密码存储等方面起着至关重要的作用。 MD5(Message-Digest Algorithm 5)是由...
MD5和SHA1是两种广泛使用的哈希函数,它们在信息技术领域中扮演着重要的角色,尤其是在数据完整性和安全性方面。这个名为"MD5&SHA1 校验(hash)工具包 by 白鹿第一帅.zip"的压缩包,提供了一种便捷的方式来验证你...
CRC32、MD5、SHA1以及SHA256是计算机科学中常见的散列函数,它们在数据完整性检查、安全认证、文件校验等方面发挥着重要作用。这些算法都是基于不同的数学原理设计,各有其特点和应用场景。 CRC32(Cyclic ...
MD5和SHA1是两种广泛使用的哈希函数,在IT领域,特别是网络安全和数据完整性验证方面扮演着重要角色。本文将详细介绍这两种数字签名技术以及如何利用CryptoAPI在C#环境中实现它们。 首先,MD5(Message-Digest ...
使用方法: 在<head></head>标签内加入一句 路径名/md5.js'> 然后可以在JS代码中使用 var md5string=hex_md5(value); 获得加密后的md5字符串, 引入sha1.js var sha1string=hex_sha1(value); 获得加密后的sha1字符串
MD5(Message-Digest Algorithm 5)和SHA-512(Secure Hash Algorithm 512)是两种广泛使用的哈希函数,它们可以将任意长度的数据转化为固定长度的哈希值,用于验证数据的完整性和一致性。 MD5由Ronald Rivest在...
运用于ASP的 MD5 SHA256 多重加密技术,根据字符串获取加密类型,属于混合加密,暴利破击完全无望!可移植到 C#/C/C++ 、ASP.NET、VB.NET 或其他类型的语言上
MD5和SHA校验和工具是计算机安全领域中用于验证文件完整性的常用方法。这些算法在数字签名、数据完整性检查以及防止数据篡改等方面扮演着重要角色。在本压缩包中,包含了一个名为"MD5_and_SHA_Checksum_Utility.exe...
MD5_and_SHA_Checksum_Utility
在Windows操作系统中,我们可以使用各种工具来验证文件的MD5、SHA-1、SHA-256以及SHA-512哈希值,这些哈希算法都是用来生成文件唯一数字指纹的方法。 标题提到的"windows校验MD5, SHA-1, SHA-256 & SHA-512工具"是...
在IT领域,数据完整性与安全性至关重要,而md5和sha1就是两种常见的校验和算法,用于验证文件是否被篡改或损坏。本工具提供了一种便捷的方式,通过CMD(命令行)操作来计算文件的md5和sha1摘要值。 MD5(Message-...
MD5和SHA是两种广泛使用的哈希函数,用于在信息技术领域验证数据的完整性和一致性。它们都是基于密码学原理设计的算法,可以将任意长度的数据转换为固定长度的哈希值,通常用作数字指纹。 MD5(Message-Digest ...
在Windows 10操作系统中,计算文件的MD5、SHA1和SHA256校验值是一项重要的任务,尤其在验证文件的完整性和安全性时。这些校验算法提供了对文件内容的一种数学摘要,使得我们可以检查文件是否在传输或存储过程中被...
MD5(Message-Digest Algorithm 5)、SHA1(Secure Hash Algorithm 1)和SHA256(Secure Hash Algorithm 2,256位版本)是常见的哈希函数,用于生成固定长度的数字指纹,常用于数据完整性校验、密码存储等领域。...
MD5(Message-Digest Algorithm 5)和SHA-1(Secure Hash Algorithm 1)是两种广泛使用的哈希函数,它们在信息安全领域扮演着至关重要的角色。哈希函数是一种将任意长度的数据转换为固定长度输出的函数,这个输出...