From 9a7b00bcffe51d2555ceedd74c9ed4fd55dc3c06 Mon Sep 17 00:00:00 2001 From: mattsaxon Date: Fri, 3 Jan 2020 15:19:51 +0000 Subject: [PATCH] A few bits of tidy --- debug/Decrypt.py | 9 ++------- pysonofflan/sonoffcrypto.py | 2 +- tests/test_cli.py | 6 +++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/debug/Decrypt.py b/debug/Decrypt.py index 7426d71..ca94db1 100644 --- a/debug/Decrypt.py +++ b/debug/Decrypt.py @@ -26,10 +26,5 @@ def Decrypt(self, encoded, iv): return plaintext -device = SonoffR3(b'b5b46dce-d365-4f2e-b507-b09269c4ddb6') -print(device.Decrypt(b'oCKuglULSEok8/xaS8ZMS9HPjpK/0WYgFrzaSnTnJSpbmKz2NCIee7Mhzvf9GU+/', b'"MDQ2OTgyMTAyMjcxODU3Ng=="')) - -device = SonoffR3(b'b5b46dce-d365-4f2e-b507-b09269c4ddb6') -print(device.Decrypt(b'2BqVsSYoQxFP43zTKxZfc1i2CYDhTX6pYp4tGySiczMDnpYAb6/UTGhKt3kbhm+P', b'HwQWNfMgpBRjODqTUcH1+A==')) - - +device = SonoffR3(b'apikey') +print(device.Decrypt(b'ciphertext', b'iv')) diff --git a/pysonofflan/sonoffcrypto.py b/pysonofflan/sonoffcrypto.py index 7b33478..a1e833b 100644 --- a/pysonofflan/sonoffcrypto.py +++ b/pysonofflan/sonoffcrypto.py @@ -26,7 +26,7 @@ def format_encryption_msg(payload, api_key, data): - payload["selfApikey"] = "cb0ff096-2a9d-4250-93ec-362fc1fe6f40" # This field needs to exist, but no idea what it is used for (https://github.com/itead/Sonoff_Devices_DIY_Tools/issues/5) + payload["selfApikey"] = "123" # This field needs to exist, but no idea what it is used for (https://github.com/itead/Sonoff_Devices_DIY_Tools/issues/5) iv = generate_iv() payload["iv"] = b64encode(iv).decode("utf-8") payload["encrypt"] = True diff --git a/tests/test_cli.py b/tests/test_cli.py index 1a06c0a..f998d58 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -67,7 +67,7 @@ def test_cli_on(self): """Test the CLI.""" runner = CliRunner() - result = runner.invoke(cli.cli, ['--device_id', 'PlugOnMock', '-l', 'DEBUG', 'on']) + result = runner.invoke(cli.cli, ['--device_id', 'PlugOnMock', 'on']) print(result.output) @@ -119,7 +119,7 @@ def test_cli_off_strip(self): def test_cli_on_encrypt(self): - start_device("PlugEncrypt", "plug") + start_device("PlugEncrypt", "plug", "testkey") """Test the CLI.""" runner = CliRunner() @@ -131,7 +131,7 @@ def test_cli_on_encrypt(self): def test_cli_on_strip_encrypt(self): - start_device("StripEncrypt", "strip") + start_device("StripEncrypt", "strip", "testkey") """Test the CLI.""" runner = CliRunner()