Skip to content

Commit

Permalink
Remove duplicate PKCS#7 padding
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Jan 8, 2025
1 parent 23afde8 commit 9d7c8d3
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/api/device.ts
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down Expand Up @@ -84,7 +83,7 @@ export class TuyaAPIConnection {
}

async encryptData(key: string, data: string): Promise<string> {
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()}`
}
Expand Down

0 comments on commit 9d7c8d3

Please sign in to comment.