【发布时间】:2021-12-04 07:38:43
【问题描述】:
我怎样才能读取像下面这样的二进制文件?
Binary2 {
sub_type: 0,
buffer: Buffer(16) [
12, 15, 64, 88, 174, 93,
16, 250, 162, 5, 122, 223,
16, 98, 207, 68
],
position: 16
}
我尝试了几件事,比如制作一个 parseInt:
错误:
NaN
或使用新的 Uint16Array():
错误:
error: TS2769 [ERROR]: No overload matches this call.
The last overload gave the following error.
Argument of type 'string' is not assignable to parameter of type 'ArrayBufferLike'.
console.log('test :', new Uint16Array(contact.firstname))
TS2771 [ERROR]: The last overload is declared here.
new(buffer: ArrayBufferLike, byteOffset?: number, length?: number): Uint16Array;
有人可以帮我读取这个二进制文件的缓冲区并解密我的 aes 数据吗?
【问题讨论】:
-
该错误消息抱怨
new Uint16Array(contact.firstname),其中contact.firstname是字符串类型(与Buffer无关),并且此contact和语句均不在您提供的代码中。你能让你的问题保持一致吗? -
@trincot 我的应用程序使用 Deno 和三方模块 god_crypto 来加密 AES 数据。我在 mongoDB 中插入“字符串”格式的数据,并使用相同的三方模块 god_crypto 解密。当我使用方法 console.log() 我有这个输出
Binary2 { sub_type: 0, buffer: Buffer(16) [ 12, 15, 64, 88, 174, 93, 16, 250, 162, 5, 122, 223, 16, 98, 207, 68 ], position: 16 }我只想得到这个对象的键“缓冲区”的值来设置在await aes.decrypt(<BUFFER>)就像在这里解释 - > github.com/invisal/god_crypto
标签: javascript node.js typescript binary