Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
1,075 additions
and
692 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Current File", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "${file}", | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import time | ||
import requests | ||
import json | ||
|
||
from zeroconf import ServiceBrowser, Zeroconf | ||
|
||
from Crypto.Hash import MD5 | ||
from Crypto.Cipher import AES | ||
from Crypto.Util.Padding import pad, unpad | ||
from base64 import b64decode | ||
|
||
class SonoffR3: | ||
|
||
def __init__(self, Apikey): | ||
|
||
h = MD5.new() | ||
h.update(Apikey) | ||
self._key = h.digest() | ||
|
||
def Decrypt(self, encoded, iv): | ||
|
||
cipher = AES.new(self._key, AES.MODE_CBC, iv=b64decode(iv)) | ||
ciphertext = b64decode(encoded) | ||
padded = cipher.decrypt(ciphertext) | ||
plaintext = unpad(padded, AES.block_size) | ||
|
||
return plaintext | ||
|
||
device = SonoffR3(b'apikey') | ||
print(device.Decrypt(b'ciphertext', b'iv')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.