Skip to content

Commit

Permalink
Modified string_to_binary() method
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenang committed Jan 23, 2018
1 parent 972c840 commit 794a2c0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@ class Tools:

@staticmethod
def string_to_binary(input:str):
binary = []
for char in input:
temp = bin(ord(char))[2:]
while(len(temp) < 8):
temp = '0' + temp
binary.append(temp)

return ''.join(binary)

@staticmethod
def string_to_binary_no_concat(input: str):
binary = []
for char in input:
binary.append(bin(ord(char))[2:])
Expand Down

0 comments on commit 794a2c0

Please sign in to comment.