abre SSL sha256 diferencia

I am using openssl 1.0.1c , linux x86_64

i am creating file contains "hello" (without new line character)

  • openssl dgst -sha256 hello_file

yo obtengo : 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03


If i am using any other online calc (1 , 2 , 3 , 4 , 5 (because of lack of reputation i cant do more hyperlinks)

yo obtengo : 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

The most confusing part is if i am trying online calculator with "hello(new line character)" luego

1 return : 5891b5b522d5df086d0ff0b110fbd9d21bb4fc7163af34d08286a2e846f6be03

and it is exactly what i am getting with openssl. While all others return

2, 3, 4 , 5 : cd2eca3535741f27a8ae40c31b0c41d4057a7a7b912b33b9aed86485d1c84676

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 ?

Gracias por adelantado

Kirill


3 convertstring.com/Hash/SHA256

4 webutils.pl/index.php?idx=sha1

5 quickhash.com

preguntado el 31 de julio de 12 a las 15:07

1 Respuestas

Tienes razón, tu 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

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..

Respondido el 20 de Septiembre de 16 a las 20:09

Thank you very match for answer - manzanas

@yabloki The question was almost year stale when I answered, but it may help someone else down the road (I was researching the same problem). How about an accept or upvote? :) - Pete

sure ! I am sorry my every answer taking about a half of a year ) - manzanas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.