Akuze
Akuze
DDeno
Created by Akuze on 4/8/2024 in #help
Importing Buffer Type
Hi there, I am having issue typing a hash. I am trying to create an encryption key and signature key, but don't know what the return types should be in Deno. In node.js, the type appears to be Buffer, but this comes up with an error in Deno. Here's the code I'm referring to:
class myClass {
_encryptionKey: Buffer; // Errors: Cannot find name 'Buffer'.deno-ts(2580)
_signatureKey: Buffer; // Errors: Cannot find name 'Buffer'.deno-ts(2580)
constructor(secret: string, domain: string) {
const keyMaterial = crypto.createHash("sha256").update(secret).digest();
this._encryptionKey = keyMaterial.subarray(0, BLOCK_SIZE);
this._signatureKey = keyMaterial.subarray(BLOCK_SIZE, 32);
}
}
class myClass {
_encryptionKey: Buffer; // Errors: Cannot find name 'Buffer'.deno-ts(2580)
_signatureKey: Buffer; // Errors: Cannot find name 'Buffer'.deno-ts(2580)
constructor(secret: string, domain: string) {
const keyMaterial = crypto.createHash("sha256").update(secret).digest();
this._encryptionKey = keyMaterial.subarray(0, BLOCK_SIZE);
this._signatureKey = keyMaterial.subarray(BLOCK_SIZE, 32);
}
}
How should I type this? I'm new to Deno, so any help is appreciated. Thanks a lot
5 replies