Last active
May 13, 2020 07:56
-
-
Save sanzaru/9035e0dd25bef72faa9a to your computer and use it in GitHub Desktop.
Simple python script to byte encode a string
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import array, sys | |
ARGV = sys.argv | |
if len(ARGV) <= 1 or not ARGV[1]: | |
print 'usage: ' + ARGV[0] + ' <string to encode>' | |
sys.exit(1) | |
inp = str(ARGV[1]) | |
bc = '' | |
for item in [elem.encode("hex") for elem in inp]: | |
bc = bc + '\\x' + item | |
print bc | |
# Decode, just for a prove | |
print bc.replace('\\x', '').decode("hex") |
That's easy. Taken the string bc from above it would be:
print bc.replace('\\x', '').decode("hex")
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how to decode back at the other end?