sh256

BSD-style digest generation script
git clone git://git.ckyln.com/sh256
Log | Files | Refs | README | LICENSE

commit abed125366b4142a6dacadcc4b947813ca6551cf
Author: Cem Keylan <cem@ckyln.com>
Date:   Mon,  5 Oct 2020 19:21:00 +0300

initial commit

Diffstat:
ALICENSE | 5+++++
AMakefile | 28++++++++++++++++++++++++++++
AREADME.md | 19+++++++++++++++++++
Asha256 | 11+++++++++++
4 files changed, 63 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,5 @@ +sh256 is in the public domain. + +To the extent possible under law, Cem Keylan <cem@ckyln.com> has waived all +copyright and related or neighbouring rights to this work. +https://creativecommons.org/publicdomain/zero/1.0/ diff --git a/Makefile b/Makefile @@ -0,0 +1,28 @@ +PREFIX = /usr/local +BINDIR = ${PREFIX}/bin + +DIGESTEXTRA = \ + md5 \ + sha1 \ + sha224 \ + sha3 \ + sha384 \ + sha512 + +all: + @echo Run \'make install\' to install + +install: + mkdir -p ${DESTDIR}${BINDIR} + cp sha256 ${DESTDIR}${BINDIR} + chmod 755 ${DESTDIR}${BINDIR}/sha256 + for bin in ${DIGESTEXTRA}; do \ + ln -sf sha256 ${DESTDIR}${BINDIR}/$${bin}; \ + done + +uninstall: + for bin in sha256 ${DIGESTEXTRA}; do \ + rm -f ${DESTDIR}${BINDIR}/$${bin}; \ + done + +.PHONY: all install uninstall diff --git a/README.md b/README.md @@ -0,0 +1,19 @@ +SH256 +===== + +Tiny shell script to create BSD-style digests using coreutils-style digest +programs. It isn't specific to sha256(1), it calls the digest necessary digest +program depending on its own name. The Makefile handles all of it anyway. + +E.g. + sha256 -> sha256sum + md5 -> md5sum + + +Installation +------------ + +The program can be installed by running: + + make install + diff --git a/sha256 b/sha256 @@ -0,0 +1,11 @@ +#!/bin/sh -e +# Shell script to create BSD style digests using coreutils style digest +# programs. Calls the digest program according to its own name. +# So, sha256 -> sha256sum, md5 -> md5sum. This makes it easier to symlink and +# use it multifunctionally. + +case "$1" in --) ;; -*|'') printf 'usage: %s [file...]\n' "${0##*/}"; exit 0; esac + +"${0##*/}sum" "$@" | while read -r digest file; do + printf '%s (%s) = %s\n' "$(printf "${0##*/}" | tr [:lower:] [:upper:])" "$file" "$digest" +done