coreutils icon indicating copy to clipboard operation
coreutils copied to clipboard

cksum: implement `-a`

Open sylvestre opened this issue 2 years ago • 6 comments

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 avatar Aug 14 '22 19:08 sylvestre

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

sylvestre avatar Aug 14 '22 19:08 sylvestre

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

sylvestre avatar Aug 14 '22 19:08 sylvestre

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?

Zopolis4 avatar Oct 09 '22 05:10 Zopolis4

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.

tertsdiepraam avatar Oct 09 '22 07:10 tertsdiepraam

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?

howjmay avatar Feb 13 '23 02:02 howjmay

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

sylvestre avatar Feb 13 '23 06:02 sylvestre