bash MT hash generation + script

From pitriss, 9 Years ago, written in Plain Text, viewed 371 times. This paste is a reply to from - go back
URL http://minetest.wjake.com/stikked/view/ae174f29/diff Embed
Viewing differences between and bash MT hash generation + script
  1. hash_pw() {
  2. echo -n "$1" \
  3. | sha1sum \
  4. | cut -d ' ' -f 1 \
  5. | xxd -r -p \
  6. | base64 \
  7. | sed -e 's/.$//';
  8. }
  9.  
  10. ---
  11. [21:58:21] <kaeza> pitriss, it's because in bash, sha1sum returns the "hexdigest", and not the raw digest
  12. [21:59:06] <kaeza> pitriss, this seems to work: https://gist.github.com/kaeza/34342260f74c1f5683db
  13. [21:59:57] <kaeza> (Minetest base64s the raw bytes of the digest)
  14. [21:59:57] --> Amaz has joined this channel (~Amaz@unaffiliated/amaz).
  15. [22:00:36] <kaeza> use as `my_hash=$(hash_pw "$user$pass")`
  16.  
  17.  
  18. --- bash script:
  19.  
  20. #!/bin/bash
  21.  
  22. hash_pw() {
  23.   echo -n "$1" | sha1sum | cut -d ' ' -f 1 | xxd -r -p | base64 | sed -e 's/.$//';
  24. }
  25. my_hash=$(hash_pw "$1$2")
  26. echo -n $my_hash
  27.  
  28.  
  29.  
  30.  

Reply to "bash MT hash generation + script"

Here you can reply to the paste above