forked from karan51ngh/RedditRefresh
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmanageText.py
More file actions
24 lines (22 loc) · 905 Bytes
/
manageText.py
File metadata and controls
24 lines (22 loc) · 905 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
import hashlib
def manageText(text_body, filee, flag_commentsPosts, post_content=None):
if flag_commentsPosts == True:
# manage a COMMENT
hash_v = text_body.encode()
hash_v = hashlib.sha256(hash_v).hexdigest()
text_body = "- **COMMENT**: \n\n" + text_body + "\n\n"
filee.write(text_body)
hash_v_body = " - **HASHED COMMENT**: \n\n" + hash_v + "\n\n"
filee.write(hash_v_body)
return hash_v
else:
# manage a POST
hash_v = text_body.encode()
hash_v = hashlib.sha256(hash_v).hexdigest()
text_body = "- **POST TITLE**: \n\n" + text_body + "\n\n"
filee.write(text_body)
text_body = "- **POST BODY**: \n\n" + post_content + "\n\n"
filee.write(text_body)
hash_v_body = " - **HASHED BODY**: \n\n" + hash_v + "\n\n"
filee.write(hash_v_body)
return hash_v