有无大佬帮忙把这段 Python 代码转换成 JavaScript
代码如下,非常感觉!
import base64 from Crypto.Cipher import AES class Encrypt(object): def __init__(self): self.key = "ABCDEXGH01234567".encode("utf8") self.length = AES.block_size self.aes = AES.new(self.key, AES.MODE_ECB) def pad(self, text): count = len(text.encode('utf-8')) add = self.length - (count % self.length) return text + (chr(add) * add) def encrypt(self, encrData): res = self.aes.encrypt(self.pad(encrData).encode("utf8")) msg = str(base64.b64encode(res), encoding="utf8") return msg if __name__ == '__main__': e = Encrypt() a = e.encrypt("12345678") print(a)