forked from axiom-team/jaklis
Decrypt message work
This commit is contained in:
parent
e08fd78131
commit
e15398445e
24
readmsg.py
24
readmsg.py
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
import os, sys, requests, json, base58, base64
|
import os, sys, requests, json, base58, base64
|
||||||
from userEnv import dunikey, pod
|
from userEnv import dunikey, pod
|
||||||
from natools import fmt, sign, get_privkey
|
from natools import fmt, sign, get_privkey, box_decrypt
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
|
rows = int(os.popen('stty size', 'r').read().split()[1])
|
||||||
|
|
||||||
#recipient = sys.argv[1]
|
#recipient = sys.argv[1]
|
||||||
recipient = get_privkey(dunikey, "pubsec").pubkey
|
recipient = get_privkey(dunikey, "pubsec").pubkey
|
||||||
nbrMsg = 5
|
nbrMsg = 5
|
||||||
|
@ -46,16 +48,18 @@ for hits in msgJSON["hits"]:
|
||||||
isMsg = hits["_id"]
|
isMsg = hits["_id"]
|
||||||
msgSrc = hits["_source"]
|
msgSrc = hits["_source"]
|
||||||
issuer = msgSrc["issuer"]
|
issuer = msgSrc["issuer"]
|
||||||
title = msgSrc["title"]
|
|
||||||
content = msgSrc["content"]
|
|
||||||
nonce = msgSrc["nonce"]
|
nonce = msgSrc["nonce"]
|
||||||
date = datetime.fromtimestamp(msgSrc["time"]).strftime("Le %d/%m/%Y à %H:%M")
|
nonce = base58.b58decode(nonce)
|
||||||
|
title = base64.b64decode(msgSrc["title"])
|
||||||
|
title = box_decrypt(title, get_privkey(dunikey, "pubsec"), issuer, nonce).decode()
|
||||||
|
content = base64.b64decode(msgSrc["content"])
|
||||||
|
content = box_decrypt(content, get_privkey(dunikey, "pubsec"), issuer, nonce).decode()
|
||||||
|
|
||||||
|
date = datetime.fromtimestamp(msgSrc["time"]).strftime(", le %d/%m/%Y à %H:%M ")
|
||||||
|
|
||||||
print("----------")
|
headerMsg = " De " + issuer + date
|
||||||
print(date)
|
print('-'.center(rows, '-'))
|
||||||
|
print(headerMsg.center(rows, '-'))
|
||||||
|
print('-'.center(rows, '-'))
|
||||||
print("Objet: " + title)
|
print("Objet: " + title)
|
||||||
print("Message: " + content)
|
print(content)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue