~cemkeylan/sh256

abed125366b4142a6dacadcc4b947813ca6551cf — Cem Keylan 2 years ago
initial commit
4 files changed, 63 insertions(+), 0 deletions(-)

A LICENSE
A Makefile
A README.md
A sha256
A  => LICENSE +5 -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/

A  => Makefile +28 -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

A  => README.md +19 -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


A  => sha256 +11 -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