1. patrick.waugh's Avatar
    Here's a handy script I wrote for those developing on *nix.

    Code:
    #! /bin/bash
    
    # SHA1 - Used to create BB persistent store key.
    # 
    # Created by P.T. Waugh MA
    # License: GPLv2, may be freely distributed and modified as deisred.
    
    if [ $# -eq 0 ]
    	then
    		echo "Usage: sha1 [-bb] string" 1>&2
    		exit 1
    fi
    
    if [ $# = 1 ]
    	then
    		str="${1}"
    	else
    		str="${2}"
    fi
    
    function reverse {
    	# Echo last byte first
    	echo -n ${1#??}
      echo -n ${1%??}
    }
    
    echo -n "${str}: "
    digest=$(echo -n $str | gpg --print-md sha1)
    if [ ! "${1}" = "-bb" ]
    	then
    		echo ${digest}
    	else
    		# Show Blackberry sha1
    		echo -n "0x"
    		set -- $digest
    		reverse $4
    		reverse $3
    		reverse $2
    		reverse $1
    		echo "L"
    fi
    
    exit 0
    Enjoy.
    12-20-08 04:09 AM
LINK TO POST COPIED TO CLIPBOARD