uutils / coreutils

Cross-platform Rust rewrite of the GNU coreutils
https://uutils.github.io/
MIT License
17.84k stars 1.28k forks source link

cksum: implement `-a` #3812

Closed sylvestre closed 1 year ago

sylvestre commented 2 years ago

Used by tests/misc/sm3sum.pl

-a, --algorithm=TYPE
    select the digest type to use. See DIGEST below.

[...]

DIGEST determines the digest algorithm and default output format:

sysv
    (equivalent to sum -s)
bsd
    (equivalent to sum -r)
crc
    (equivalent to cksum)
md5
    (equivalent to md5sum)
sha1
    (equivalent to sha1sum)
sha224
    (equivalent to sha224sum)
sha256
    (equivalent to sha256sum)
sha384
    (equivalent to sha384sum)
sha512
    (equivalent to sha512sum)
blake2b
    (equivalent to b2sum)
sm3
    (only available through cksum)

When checking, the input should be a former output of this program, or equivalent standalone program.
sylvestre commented 2 years ago

See https://github.com/uutils/coreutils/issues/3811

sylvestre commented 2 years ago

also tested by tests/misc/cksum-a.sh

Zopolis4 commented 2 years ago

I'm looking into working on this-- Is it ok if I pull in an external library for some hashes, and should I move the sysv and bsd sums from sum into uucore so they can be shared?

tertsdiepraam commented 2 years ago

Yeah I think that's fine. Be sure to check out the hashsum util as well. There's probably some code there that you can reuse too. Also, you can start with an implementation that only supports a few algorithms.

howjmay commented 1 year ago

Hi @tertsdiepraam as you know I am working on this issue. I have a question about reusing the code in hashsum. I think I may reuse some code in hashsum/digest.rs. Should I move them to a place for common functions? Or I just make a copy of those codes to cksum?

sylvestre commented 1 year ago

For common functions, we move them in src/uucore/src/lib/features :)