linux 和 python 中的 md5
md5 in linux and python
我正在使用 md5 算法对 python 和 linux 中的相同字符串进行哈希处理,但我得到不同的值,有人能指出错误吗
在 linux 中:
echo "logdir" | md5sum - | awk '{print }'
gives: aba76197efa97e6bd4e542846471b391
在python中:
md5.new("logdir".encode('utf-8')).hexdigest()
gives: ee6da4c228cfaebfda7f14e4371a097d
echo
将添加换行符,除非您明确告诉它不要通过 echo -n
.
$ echo -n "logdir" | md5sum - | awk '{print }'
ee6da4c228cfaebfda7f14e4371a097d
来自man echo:
DESCRIPTION
Echo the STRING(s) to standard output.
-n do not output the trailing newline
我正在使用 md5 算法对 python 和 linux 中的相同字符串进行哈希处理,但我得到不同的值,有人能指出错误吗
在 linux 中:
echo "logdir" | md5sum - | awk '{print }'
gives: aba76197efa97e6bd4e542846471b391
在python中:
md5.new("logdir".encode('utf-8')).hexdigest()
gives: ee6da4c228cfaebfda7f14e4371a097d
echo
将添加换行符,除非您明确告诉它不要通过 echo -n
.
$ echo -n "logdir" | md5sum - | awk '{print }'
ee6da4c228cfaebfda7f14e4371a097d
来自man echo:
DESCRIPTION
Echo the STRING(s) to standard output.
-n do not output the trailing newline