-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAscii2Hex.py
More file actions
37 lines (17 loc) · 911 Bytes
/
Ascii2Hex.py
File metadata and controls
37 lines (17 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#Created by ignorant05 aka Oussama Baccara
#! /usr/bin/env python3
#Importing sys module to handle terminal, user input and errors
#####################################################################################################################
import sys
if len(sys.argv) < 2 :
print("Usage : python3 Ascii2Hex.py <Text-to-encode>")
sys.exit(1)
txt = sys.argv[1]
#####################################################################################################################
#The conversion function
#####################################################################################################################
def encode (txt):
hex_string = ''.join(hex(ord(i))[2:].upper().zfill(2) for i in txt)
return hex_string
print(encode(txt))
#####################################################################################################################