老笔记整理六:MD5的小作死
Posted shiningsun
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了老笔记整理六:MD5的小作死相关的知识,希望对你有一定的参考价值。
MD5算法具有以下特点:
1、压缩性:任意长度的数据,算出的MD5值长度都是固定的。
2、容易计算:从原数据计算出MD5值很容易。
3、抗修改性:对原数据进行任何改动,哪怕只修改1个字节,所得到的MD5值都有很大区别。
4、弱抗碰撞:已知原数据和其MD5值,想找到一个具有相同MD5值的数据(即伪造数据)是非常困难的。
5、强抗碰撞:想找到两个不同的数据,使它们具有相同的MD5值,是非常困难的。
然后我就在想,如果把一个字符串用MD5加密过以后再不停的进行MD5加密,会得到什么样的结果呢?遂有了以下代码:
using System;
using System.IO;
using System.Text;
using System.Security.Cryptography;
namespace MD5puzzle
{
class Program
{
static void Main(string[] args)
{
Int64 i = 0, j = 0;
Int64 max = 10000000;
string niconiconi = "niconiconi";
string niconi, nico=niconiconi;
StreamWriter swOut = new StreamWriter(@"E:\md5.txt", false, Encoding.Default);
for (i = 0; (i < max) && (j == 0); i++)
{
niconi = does.MD5(nico);
if (niconi == niconiconi)
{
j = 1;
}
swOut.WriteLine(niconi + " " + i);
nico = niconi;
}
System.Console.WriteLine("Finish");
System.Console.Read();
}
public void domd5p()
{
Int64 i = 0, j = 0;
Int64 max = 100000000;
string nico = does.MD5("niconiconi");
string niconi;
for (i = 0; (i < max) && (j == 0); i++)
{
niconi = does.MD5(nico);
if (niconi == nico)
{
j = 1;
}
System.Console.WriteLine("NO." + i + "_" + niconi);
nico = niconi;
}
System.Console.Read();
}
}
class does
{
public static string MD5(string Sourcein)
{
MD5CryptoServiceProvider MD5CSP = new MD5CryptoServiceProvider();
byte[] MD5Source = System.Text.Encoding.UTF8.GetBytes(Sourcein);
byte[] MD5Out = MD5CSP.ComputeHash(MD5Source);
return Convert.ToBase64String(MD5Out);
}
}
}
这里我把数据写到了md5.txt里。
当中改动过上限。括号里面的是上限,大家可以感受一下
没错,那个只有5百万次的已经有160MB了。我家的电脑实在比较无能。我玩到5百万就玩不下去了,有兴趣的同学可以下下来去试试。下面贴出前100个md5码
rRIpUGNjjelWrYVo1BInLA== 0
UrjRsTpLZN0WL72SDuid4w== 1
6MICH12/VVlQPlcqAyy3Aw== 2
3dOqdPJsUmBXwLAQaDGGHQ== 3
T+DsqpgWx5k/uZMtY5V1ig== 4
nMD0ewc/sG4F48SFyapgyA== 5
yYQi6mMUkxq8Hrf096EkKw== 6
+UzysWlAHkxNs33qK5BLCw== 7
h/9vU01bY5OQvCzgFiPzKA== 8
iUg4RSM4dc+C42bA7tddVQ== 9
MauXvC2lY72PuvNJUEO0pg== 10
sE75QOo3pLLz6p6WGA4gHA== 11
5Dpk6YBnDklIi/hpodU2sQ== 12
htzQz2LvmXEkq/ZC+KLJCQ== 13
aRX22z67lAsOqtTH+Tw8cQ== 14
lDklDi/l3/evDZxpPMgueQ== 15
FwaH5M0IfUFI8JxSGhhXhw== 16
Fl/Nn0ndML7kAzVy7eBz2Q== 17
721lIGZeXmLWUJFLoVKnzw== 18
rkeOoYGytxnNd5IbCjmXkg== 19
Ka8JEiL243jL3Af6sEPFvg== 20
A/IjZkj0a9HuHeTbOOiVsw== 21
P+AUgz4lMx2zyIwV1cE1+w== 22
T0Y7bPSx3e1Ihly2vaOK2w== 23
GmYdOwKhkQK9q+qQP8YweA== 24
coMC8O6Y/nMXj/800kZK3w== 25
bvCqEuLmSoHXgRfPhLy1uw== 26
n9jqVhYvunn8RPNeqA8z9g== 27
J3roDv2oLFdx5kd5+I6Fsw== 28
EtihsewoZlvcv7otGqTZ6w== 29
cub9APkZUzsvDAaV0Wmuog== 30
Fx3sYg0FkmEodUDJ9+e9hw== 31
IqrobIoalFbAF1Ien1/zAg== 32
Pb/fqpq2WEatKNnXEUx8Tw== 33
DJL8TLWnUvPndt5zTZaEcw== 34
BsUzuXzY07VTX/7f6TrVMQ== 35
OukV8qcNJPMd2tpAIaNYew== 36
jHbVc69HjE6fxSdyQKOOSA== 37
u5U6EFealDnTtVNYr6JMrQ== 38
dfTeboDPc0Zs8AE7y7Ryog== 39
THZ7l6lgnsah40pt1CIemA== 40
fOCcL2r2evM2QrwZnQeBPg== 41
byRrkNKG6erMWIA7uTqYxw== 42
e5qvFWng2siIbBiqCtWzxw== 43
6o6PosWy4h8nB+N/Ll9Wfg== 44
aI4xMxmdOLGr50p8PfXwKA== 45
sTtqsdyqgQYeHeziUwcXqQ== 46
mHEkXO/CSkdkJGUJ+9zfbg== 47
u8FTFCqdDE9BemXf6S5+iw== 48
vSkD5Loe4tWoVMSP5+zg7Q== 49
pyILkblGKZTcPs7iYRvcjw== 50
7f8iNhqqqJ9Jrs38lxtzhg== 51
3J8FT6WJCn/L1S3DHgXaSg== 52
f+aU3Kzm9CEqa02hBwlh9A== 53
gUPwk0TORS0MAZih0ksPUA== 54
mWIy2fhoA6b000+0ikpWTQ== 55
eQfD0zcukAwp37L6vJj6iQ== 56
U2wE534uWJTe5UAnAAu6gw== 57
VoL6uzLMskTCmil+C49Cpg== 58
1nEmQmBACaL0XVbUiSxv0Q== 59
BJxt/vpHsDVfizCvl5uRBg== 60
P/9excuqnyAxugIY4SLGgA== 61
O2qqoVKGa2RcW9b516d6Ww== 62
4Y3ULLcU+sOvKBjN8lEBvA== 63
hgWxbnIiZwXIYQ4FBSXTGg== 64
O7cxBcVgMD3ayM1H83cOhA== 65
x2xN7L/jccWH32bzzhk9ag== 66
setWXmUwVLncbIVZbnrVrg== 67
PgKpptzklLuLySSwU+zrJg== 68
fcHiicljN4dxG14Mer3ZAQ== 69
XG/9yosdOJ5NeeyP6JSG9A== 70
ETG8Fold3DHsmXiNvMxiFQ== 71
0RCECvl47EJaiYvNp7GHYA== 72
UQzRsVFXDbMPrO/cWeDj8g== 73
ogfGyPme4UxBEl6l/eWsPA== 74
z/C5G8525jGcvi5eYrWuTg== 75
Og7XbR6gzKji2WA2R2JnHQ== 76
/ZlcPNR70j+eVkPmim8v2Q== 77
pzspFErbLd8IPfoduULddA== 78
wYMqORQQ6XjQtwo4ewRD9Q== 79
UOhZzCdeUKplKV9J1TKJ0A== 80
0tVvT87rDcofgnud4mihbQ== 81
OKr/3PJN6FOO6xnhFAzW9w== 82
q0x6G834+fE6rbKBDORX9Q== 83
7/u3D3au9aixMKDpizP43Q== 84
9fa3y05Ao5kH8GQIIDiqqg== 85
VDhlIKghoLSbK3GJI3iREg== 86
S203+Ud/EhpNlvruXTNv3w== 87
NkyVsm2M/UcCGHX0ne1i3Q== 88
u+6SeE2UTAbe2IicGx7XUQ== 89
CPiFazZNP6LHpOIK86vkzg== 90
CgttspQziSWrq4H7QqshlA== 91
MT/YfWKSquFvkRBLYLyciA== 92
e3okGK6a2xqlqojhAI/y1Q== 93
KkJq1mGfoiJXjrQXvt3QSQ== 94
fuBEgx4H2U0Oy89TI4VgMQ== 95
Pb8U1wlvgJ8RaSn1KC/y6A== 96
uSy3xXweQiQRTwOMcA2RJA== 97
lc7RHW8ew5KWJcZoJg1wuw== 98
s+kWyYo+xGfgjZ4FI8IuaA== 99
以上是关于老笔记整理六:MD5的小作死的主要内容,如果未能解决你的问题,请参考以下文章