错误:Can't访问词法声明

Error: Can't access lexical declaration

本文关键字:访问 词法 声明 Can 错误      更新时间:2023-09-26
let textBytes = ctypes.uint8_t("hello"); 
let a = new SECItem;
a.type = siBuffer;
a.data = textBytes.address();
a.len = textBytes.length;

我得到ReferenceError:在初始化之前无法访问词法声明textBytes。

我无法重现您得到的参考错误,但我认为更改

let textBytes = ctypes.uint8_t("hello"); 

因为这将TypeError: expected type uint8_t, got "hello"抛出到

let textBytes = ctypes.uint8_t.array()("hello"); 

这将给您一个以null结尾的字符串,长度为6。如果您希望其长度为5,没有空终止,则执行let textBytes = ctypes.uint8_t.array(5)("hello");

正如我所想的,改变

let a = new SECItem;

let a = SECItem();

或者CCD_ 3,它们都是相同的。

如果这还不能解决问题,请分享SECItem的结构以及什么是siBuffer