Ejabberd community version compatibility

merged loe + thepug forks
changed for compatibility with current processone/master branch of ejabberd (a.k.a. ejabberd-community), after the change to binary type for strings
fixed an off by one problem
updated sha to latest module name for p1_sha