Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ***************************************************************************
- # This function encode a sting in md5 hash of 32 characters. You can short
- # the length with the second parameter.
- #
- # @param string $1 string (required)
- # @param integer $2 length (option, default: 32)
- # @return string
- # @example: md5 "Hello World" 8
- function md5() {
- local length=${2:-32}
- local string=$( echo -n "$1" | md5sum | awk '{ print $1 }' )
- echo ${string:0:${length}}
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement