[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: sha256sum --text generating blank spaces and hyphens?



Albretch Mueller wrote: 
> On 4/26/23, Andy Smith <andy@strugglers.net> wrote:
> > If you're referring to the space and then the file name ("-" in case
> > of stdin) on the end, you can just select only the first output up
> > to whitespace with e.g. awk:
> >
> >     _SHA256=$(printf '%s' "${_TXT}" | sha256sum | awk '{print $1}')
> 
>  Yes, you could but I am trying to find out why this is happening
> instead of truncating the string when a space appears because I don't
> think what would be safe.

The white space and the - are not part of the sha256, they are
emitted by sha256sum as a courtesy. You can safely remove
everything starting with the first whitespace.

> >> // __ $_SHA256:
> >> |7d5895cb24ab49692a8ad495e036074fec8e61b22040544f02a9b69c926dbdeb  -|
> >
> > I only see harmless hexadecimal chars there.
> >
> >>  I am trying to avoid funky characters and sha256sum --text still
> >> generates them!?!
> >
> > Where are there "funky chars"?
> 
>  This is the first time I have seen blank spaces and hyphens in a text
> segment's sum. Those characters might be confusing.

The white space and the - are not part of the sha256, they are
emitted by sha256sum as a courtesy. You can safely remove
everything starting with the first whitespace.

>  Why is that happening? How could it be avoided? COuld you set the
> characters used in the representation of a sum?

The white space and the - are not part of the sha256, they are
emitted by sha256sum as a courtesy. You can safely remove
everything starting with the first whitespace.

The only characters used in the sha256 hash itself are [a-f] and
[0-9]

-dsr-


Reply to: