在linux命令中等同于md5哈希 [英] Equivalent of md5 hashing in linux commands
本文介绍了在linux命令中等同于md5哈希的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在C中有以下代码:
u_char buf [64] =hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha;
//通过缓冲区生成MD5哈希
MD5_Init(& ctx);
MD5_Update(& ctx,buf,sizeof(buf));
MD5_Final(buf,& ctx);
MD5_Init
, MD5_Update
和 MD5_Final
来自openssl库。上面的代码使MD5哈希通过缓冲区 buf
。
我想用linux命令使用 md5sum
$ echo -nhahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha| md5sum
但我没有得到相同的结果
在linux命令中,md5散列的等价物是什么?
解决方案
实际上, md5sum
是等效的。
打印出一个换行符。试试
echo -n hahaha .... | md5sum
。
I have the following code in C
u_char buf[64] = "hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha";
//Make MD5 hash over buffer
MD5_Init(&ctx);
MD5_Update(&ctx, buf, sizeof(buf));
MD5_Final(buf, &ctx);
MD5_Init
, MD5_Update
and MD5_Final
are from openssl library.
The above code make a MD5 hash over the buffer buf
.
I want to make the same thing with linux command using md5sum
$echo -n "hahahahahahahahahahahahahahahahahahahahahahahahahahahahahahahaha" | md5sum
but I did not get the same result
What is the equivalent of md5 hashing in linux commands?
解决方案
Actually, md5sum
is the equivalent.
echo
prints out a new-line character. Try echo -n hahaha.... | md5sum
.
这篇关于在linux命令中等同于md5哈希的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文