For short, as shown below:
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest() 'e1b8fa8fe09c295811063bb76cefc337'
"hongy...@gmail.com" <hongy...@gmail.com> writes:
For short, as shown below:
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest() 'e1b8fa8fe09c295811063bb76cefc337'
On Tuesday, October 12, 2021 at 8:03:58 PM UTC+8, hongy...@gmail.com wrote:
On Tuesday, October 12, 2021 at 6:25:43 PM UTC+8, Ben Bacarisse wrote:
"hongy...@gmail.com" <hongy...@gmail.com> writes:
For short, as shown below:
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Thank you for pointing this out. I confirmed it with the following command:Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest() 'e1b8fa8fe09c295811063bb76cefc337'
$ cat -A <<< 'TASCJO3RJMVKWDJKXLZM'
TASCJO3RJMVKWDJKXLZM$
But how to supply string for md5sum without '\n'?I see. Here it is:
$ echo -n 'TASCJO3RJMVKWDJKXLZM' | md5sum
e9032994dabac08080091151380478a2 -
On Tuesday, October 12, 2021 at 6:25:43 PM UTC+8, Ben Bacarisse wrote:
"hongy...@gmail.com" <hongy...@gmail.com> writes:
For short, as shown below:'e1b8fa8fe09c295811063bb76cefc337'
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest()
Thank you for pointing this out. I confirmed it with the following command:
$ cat -A <<< 'TASCJO3RJMVKWDJKXLZM'
TASCJO3RJMVKWDJKXLZM$
But how to supply string for md5sum without '\n'?
On Tuesday, October 12, 2021 at 6:25:43 PM UTC+8, Ben Bacarisse wrote:
"hongy...@gmail.com" <hongy...@gmail.com> writes:
For short, as shown below:
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Thank you for pointing this out. I confirmed it with the following command:Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest() 'e1b8fa8fe09c295811063bb76cefc337'
$ cat -A <<< 'TASCJO3RJMVKWDJKXLZM'
TASCJO3RJMVKWDJKXLZM$
But how to supply string for md5sum without '\n'?
On Tuesday, October 12, 2021 at 8:19:28 PM UTC+8, hongy...@gmail.com wrote:
On Tuesday, October 12, 2021 at 8:03:58 PM UTC+8, hongy...@gmail.com wrote: >> > On Tuesday, October 12, 2021 at 6:25:43 PM UTC+8, Ben Bacarisse wrote:
I see. Here it is:"hongy...@gmail.com" <hongy...@gmail.com> writes:Thank you for pointing this out. I confirmed it with the following command:
For short, as shown below:'e1b8fa8fe09c295811063bb76cefc337'
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest()
$ cat -A <<< 'TASCJO3RJMVKWDJKXLZM'
TASCJO3RJMVKWDJKXLZM$
But how to supply string for md5sum without '\n'?
$ echo -n 'TASCJO3RJMVKWDJKXLZM' | md5sum
e9032994dabac08080091151380478a2 -
So, it seems that the `<<<' will also append `\n' at the end of the string.
HZ
But how to supply string for md5sum without '\n'?
On Tuesday, October 12, 2021 at 8:19:28 PM UTC+8, hongy...@gmail.com wrote:
On Tuesday, October 12, 2021 at 8:03:58 PM UTC+8, hongy...@gmail.com wrote: >>> On Tuesday, October 12, 2021 at 6:25:43 PM UTC+8, Ben Bacarisse wrote:
I see. Here it is:"hongy...@gmail.com" <hongy...@gmail.com> writes:Thank you for pointing this out. I confirmed it with the following command: >>>
For short, as shown below:'e1b8fa8fe09c295811063bb76cefc337'
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest()
$ cat -A <<< 'TASCJO3RJMVKWDJKXLZM'
TASCJO3RJMVKWDJKXLZM$
But how to supply string for md5sum without '\n'?
$ echo -n 'TASCJO3RJMVKWDJKXLZM' | md5sum
e9032994dabac08080091151380478a2 -
So, it seems that the `<<<' will also append `\n' at the end of the string.
HZ
Right, it's saving a string into a temp file and than using that as
the input to the command so, since every line in a POSIX text file
must end in `\n`, `<<<` has to add one. It's equivalent to manually
writing:
tmp=$(mktemp) &&
printf '%s\n' 'TASCJO3RJMVKWDJKXLZM' > "$tmp" &&
md5sum < "$tmp"
rm -f -- "$tmp"
Ed Morton <morto...@gmail.com>:
Right, it's saving a string into a temp file and than using that as
the input to the command so, since every line in a POSIX text file
must end in `\n`, `<<<` has to add one. It's equivalent to manually >writing:
tmp=$(mktemp) &&On my debian linux machine it's more like
printf '%s\n' 'TASCJO3RJMVKWDJKXLZM' > "$tmp" &&
md5sum < "$tmp"
rm -f -- "$tmp"
(
tmp="$(mktemp)" &&
printf '%s\n' 'TASCJO3RJMVKWDJKXLZM' > "$tmp" &&
exec 0< "$tmp" &&
rm -f -- "$tmp" &&
exec md5sum
)
On 2021-10-12, hongy...@gmail.com <hongy...@gmail.com> wrote:
But how to supply string for md5sum without '\n'?$ printf '%s' 'TASCJO3RJMVKWDJKXLZM' | md5
e9032994dabac08080091151380478a2
--
Christian "naddy" Weisgerber na...@mips.inka.de
On 2021-10-12, hongy...@gmail.com <hongy...@gmail.com> wrote:
On Tuesday, October 12, 2021 at 8:19:28 PM UTC+8, hongy...@gmail.com wrote:
On Tuesday, October 12, 2021 at 8:03:58 PM UTC+8, hongy...@gmail.com wrote:
On Tuesday, October 12, 2021 at 6:25:43 PM UTC+8, Ben Bacarisse wrote: >> > > "hongy...@gmail.com" <hongy...@gmail.com> writes:I see. Here it is:
Thank you for pointing this out. I confirmed it with the following command:
For short, as shown below:'e1b8fa8fe09c295811063bb76cefc337'
$ md5sum <<< 'TASCJO3RJMVKWDJKXLZM'
e1b8fa8fe09c295811063bb76cefc337 -
$ ipython
In [1]: from hashlib import md5
In [2]: my_str='TASCJO3RJMVKWDJKXLZM'
In [3]: md5(my_str.encode('utf-8')).hexdigest()
Out[3]: 'e9032994dabac08080091151380478a2'
Any hints for this behavior?
md5("TASCJO3RJMVKWDJKXLZM\n".encode('utf-8')).hexdigest()
$ cat -A <<< 'TASCJO3RJMVKWDJKXLZM'
TASCJO3RJMVKWDJKXLZM$
But how to supply string for md5sum without '\n'?
$ echo -n 'TASCJO3RJMVKWDJKXLZM' | md5sum
e9032994dabac08080091151380478a2 -
So, it seems that the `<<<' will also append `\n' at the end of the string.
HZFrom man bash
Here Strings
A variant of here documents, the format is:
[n]<<<word
The word undergoes tilde expansion, parameter and variable expansion, command substitu-
tion, arithmetic expansion, and quote removal. Pathname expansion and word splitting are
not performed. The result is supplied as a single string, with a newline appended, to
the command on its standard input (or file descriptor n if n is specified).
Note the second last line.
On Tue, 12 Oct 2021 08:03:55 -0400, hongy...@gmail.com <hongyi.zhao@gmail.com> wrote:
But how to supply string for md5sum without '\n'?
$ echo -n 'TASCJO3RJMVKWDJKXLZM' |md5sum
e9032994dabac08080091151380478a2 -
David W. Hodgins wrote:
On Tue, 12 Oct 2021 08:03:55 -0400, hongy...@gmail.com <hongy...@gmail.com> wrote:
But how to supply string for md5sum without '\n'?
$ echo -n 'TASCJO3RJMVKWDJKXLZM' |md5sumOnly if you use a version of echo that does not conform to UNIX
e9032994dabac08080091151380478a2 -
requirements (even though it may conform to POSIX requirements).
POSIX allows -n to be special, but UNIX does not. A UNIX-conforming
echo does this:
$ echo -n foo
-n foo
$
The portable way to omit the newline is to use printf.
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 61:51:12 |
Calls: | 6,654 |
Files: | 12,200 |
Messages: | 5,331,620 |