hosh
hosh copied to clipboard
encoders and hashing
Problem
In https://github.com/golang-migrate/migrate/blob/master/README.md contains this:
It's easiest to always run the URL parts of your DB connection URL (e.g. username, password, etc) through an URL encoder. See the example Python snippets below:
$ python3 -c 'import urllib.parse; print(urllib.parse.quote(input("String to encode: "), ""))'
String to encode: FAKEpassword!#$%&'()*+,/:;=?@[]
FAKEpassword%21%23%24%25%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D
$ python2 -c 'import urllib; print urllib.quote(raw_input("String to encode: "), "")'
String to encode: FAKEpassword!#$%&'()*+,/:;=?@[]
FAKEpassword%21%23%24%25%26%27%28%29%2A%2B%2C%2F%3A%3B%3D%3F%40%5B%5D
$
this is suboptimal for several reasons (e.g. requires python, verbosity, hard to read).
Solution
Provide commands for encode/decode (URL, base64, etc) and hashing (md5, sha1, sha2) by using Java classes e.g. Base64 or MessageDigest.
Benefit Easy to use and portable commands for encoding, decoding and hashing.
- [ ] base64
- [ ] md5
- [ ] sha1
- [ ] sha2