-
Notifications
You must be signed in to change notification settings - Fork 0
/
reddit_encode_binary.py
64 lines (52 loc) · 1.62 KB
/
reddit_encode_binary.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"""
CSEC 791 MS Project
Grace Lombardi
Reddit Covert Channel
Encode Binary
"""
import praw
import reddit_config
def authenticate():
"""
This function authenticates to the reddit api.
"""
reddit = praw.Reddit(client_id=reddit_config.client_id,
client_secret=reddit_config.client_secret,
user_agent=reddit_config.user_agent,
redirect_uri=reddit_config.redirect_uri,
refresh_token=reddit_config.refresh_token)
return reddit
def get_message_input():
"""
This function prompts the user for a message to encode and then returns a list of all characters
in the message.
"""
message = input("Enter the message to encode: ")
message = message.replace(" ", "")
chars = list(message)
return chars
def convert_to_binary(chars):
"""
This function coverts every character in the list to their binary equivalent.
"""
binary = ''.join(format(ord(char), '08b') for char in chars)
return binary
def main():
"""
This is the main encoding function.
"""
message = get_message_input()
binary = convert_to_binary(message)
reddit = authenticate()
submission = reddit.submission("dgx575")
for binary_number in binary:
if binary_number == '0':
comment = "I disagree!"
submission.reply(body=comment)
if binary_number == '1':
comment = "I agree!"
submission.reply(body=comment)
submission.reply(body='Boom!')
print("Finished Adding Comments to Hide Message")
if __name__ == '__main__':
main()