openssl sha256差异 [英] openssl sha256 diff
问题描述
我正在使用openssl 1.0.1c,linux x86_64
I am using openssl 1.0.1c , linux x86_64
我正在创建的文件包含"hello"(没有换行符)
i am creating file contains "hello" (without new line character)
- openssl dgst -sha256 hello_file
我得到了 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
如果我使用任何其他在线计算( 1 , 2 ,3,4,5(由于缺乏名誉,我无法做更多的超链接)
If i am using any other online calc (1 , 2 , 3 , 4 , 5 (because of lack of reputation i cant do more hyperlinks)
我得到了: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
最令人困惑的部分是我是否在尝试使用你好(换行符)" 的在线计算器 然后
The most confusing part is if i am trying online calculator with "hello(new line character)" then
1返回: 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
而这正是我从openssl获得的东西.当所有其他人回来时
and it is exactly what i am getting with openssl. While all others return
2、3、4、5: cd2eca3535741f27a8ae40c31b0c41d4057a7a7b912b33b9aed86485d1c84676
我知道回声引起的新行问题,但是我不知道每个文件都附有新行.那我如何在没有新行字符的情况下获取文件sha256?所有其他计算器都不对吗?
I knew about new line issue with echo, but i didn't knew that each file appended with the new line.So how can i get sha256 of file without new line character ? And what is wrong with all other calculators ?
预先感谢
基里尔
3 convertstring.com/Hash/SHA256
3 convertstring.com/Hash/SHA256
4 webutils.pl/index.php?idx=sha1
4 webutils.pl/index.php?idx=sha1
5 quickhash.com
5 quickhash.com
推荐答案
您是正确的,您的hello_file
有换行符:
You are correct, your hello_file
has a newline:
$ echo 'hello' > hello_file; openssl sha256 hello_file; xxd hello_file
SHA256(hello_file)= 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03
0000000: 6865 6c6c 6f0a hello.
删除新行将取决于您的编辑器,如果您的情况与我发此帖子时的情况类似,弄乱密码的散列,您可以执行以下操作:
Removing the new line would depend on your editor, if your situation is similar to mine when i found this post, messing with a hash of a password you can just do something like this:
$ echo -n 'hello' > hello_file; openssl sha256 hello_file; xxd hello_file
SHA256(hello_file)= 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
0000000: 6865 6c6c 6f hello
您可以执行以下操作删除最后一个字符(或两个):
You can do something like this to remove the last character(or two):
$ echo "hello" > hello_file; od -c hello_file; truncate hello_file --size=-1; od -c hello_file
0000000 h e l l o \n
0000006
0000000 h e l l o
0000005
其他计算器似乎都在添加dos样式回车符+新行
It looks as if the other calculators are appending a dos style carriage return + new line
$ echo -en 'hello\r\n' > hello_file; openssl sha256 hello_file; xxd hello_file
SHA256(hello_file)= cd2eca3535741f27a8ae40c31b0c41d4057a7a7b912b33b9aed86485d1c84676
0000000: 6865 6c6c 6f0d 0a hello..
这篇关于openssl sha256差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!