Skip to content

Instantly share code, notes, and snippets.

@clayball
Created December 19, 2017 17:39
Show Gist options
  • Select an option

  • Save clayball/b3267a4eddd6f59871b8a76c02a96665 to your computer and use it in GitHub Desktop.

Select an option

Save clayball/b3267a4eddd6f59871b8a76c02a96665 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
# @_clayball
# A quick helper script for encoding and decoding hex.
# Use positional arguments
try:
action = sys.argv[1]
except:
print 'The first argument must be encode or decode'
exit()
try:
string = sys.argv[2]
except:
print 'The second argument must be the string to encode|decode'
exit()
if action == 'encode':
result = str(string).encode("hex")
if action == 'decode':
result = str(string).decode("hex")
print 'The ' + action + 'd string is below'
print ''
print result
print ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment