libk  Artifact [45c1076b3a]

Artifact 45c1076b3a230859fbd6c97a7d2ff6aca8c24ed808d41fec8fc53e260e9f0d09:


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

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


if test "$id_mode" = "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