libk  Artifact [5d0ff4e06b]

Artifact 5d0ff4e06bf47fc610ea94fe1f23cfb25314888ddee664024aefb52f28f6dc67:


#!/usr/bin/env sh
. global/common.sh

origin=1566169297
now=$(date +%s)
delta=$(expr $now - $origin)


if test "$1" = "private"; then
	# for privacy's sake, we're not to show
	# the hostname. instead, we calculate a
	# hash based on the  time delta and the
	# output of uname -a for extra entropy
	if has "$HASH"; then
		hash="$HASH"
	elif has sha1; then
		hash=sha1
	elif has sha1sum; then
		hash=sha1sum
	else
		say "cannot find a hashing function; privacy mode cannot be used"
		exit 1
	fi

	h=$(printf "%x%s" "$delta" "$(uname -a)" | $hash)
	echo ${h:1:7}
else
	printf "%x:%s" $delta $(uname -n)
fi