From 9d7c8d391aa0ddc7e66a8526856924790620c212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Szczodrzy=C5=84ski?= Date: Wed, 8 Jan 2025 16:32:55 +0100 Subject: [PATCH] Remove duplicate PKCS#7 padding --- src/api/device.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/api/device.ts b/src/api/device.ts index 241d1ba..67ce66f 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -1,6 +1,5 @@ import aesEcb from "aes-ecb" -import { pad } from "pkcs7-padding" -import { ObjectType } from "../types" +import { ObjectType, RequestContext } from "../types" import { b64decode, bin2hex, md5 } from "../utils" type DeviceResponse = { @@ -84,7 +83,7 @@ export class TuyaAPIConnection { } async encryptData(key: string, data: string): Promise { - const encrypted = aesEcb.encrypt(key.substring(0, 16), pad(data)) + const encrypted = aesEcb.encrypt(key.substring(0, 16), data) const encryptedArray = b64decode(encrypted) return `data=${bin2hex(encryptedArray).toUpperCase()}` }