- hash_pw() {
- echo -n "$1" \
- | sha1sum \
- | cut -d ' ' -f 1 \
- | xxd -r -p \
- | base64 \
- | sed -e 's/.$//';
- }
- ---
- [21:58:21] <kaeza> pitriss, it's because in bash, sha1sum returns the "hexdigest", and not the raw digest
- [21:59:06] <kaeza> pitriss, this seems to work: https://gist.github.com/kaeza/34342260f74c1f5683db
- [21:59:57] <kaeza> (Minetest base64s the raw bytes of the digest)
- [21:59:57] --> Amaz has joined this channel (~Amaz@unaffiliated/amaz).
- [22:00:36] <kaeza> use as `my_hash=$(hash_pw "$user$pass")`
- --- bash script:
- #!/bin/bash
- hash_pw() {
- echo -n "$1" | sha1sum | cut -d ' ' -f 1 | xxd -r -p | base64 | sed -e 's/.$//';
- }
- my_hash=$(hash_pw "$1$2")
- echo -n $my_hash