-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsodium.py
More file actions
25 lines (17 loc) · 823 Bytes
/
sodium.py
File metadata and controls
25 lines (17 loc) · 823 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
import os
import base64
import pysodium as s
from Authwave.Cipher.EncryptedMessage import EncryptedMessage
from Authwave.Cipher.PlainTextMessage import PlainTextMessage
from Authwave.Cipher.Key import Key
sharedKey = Key()
message = PlainTextMessage("This is the test message @~::>>>?>><<")
print("Message to send: " + str(message))
cipherText = message.encrypt(sharedKey)
print("Shared Key: " + str(base64.b64encode(sharedKey.getBytes())))
print("IV: " + str(base64.b64encode(message.getIv().getBytes())))
print("Cipher: " + str(base64.b64encode(cipherText.getBytes())))
encryptedMessage = EncryptedMessage(base64.b64encode(cipherText.getBytes()), message.getIv())
decryptedMessage = encryptedMessage.decrypt(sharedKey)
print(str(decryptedMessage))
print(cipherText.getQueryString("https://cipher-test.g105b.com"))