buffer issue fixed
This commit is contained in:
parent
50329b9e4e
commit
66a6a983ed
@ -115,7 +115,7 @@ export default function ProfilePage({
|
||||
</div>
|
||||
</div>
|
||||
<div className="mx-auto max-w-[800px] space-y-6">
|
||||
<div className="flex max-w-2xl flex-col gap-5 px-5">
|
||||
<div className="flex max-w-2xl flex-col gap-4 px-4">
|
||||
{demo.map((e) => (
|
||||
<SubscriptionCard key={e.id} {...e} />
|
||||
))}
|
||||
|
@ -148,7 +148,7 @@ export default function Header({ event }: { event: NDKEvent }) {
|
||||
<ProfileInfo pubkey={pubkey} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex items-center gap-3">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
{!!currentUser && currentUser.pubkey === pubkey && (
|
||||
<>
|
||||
<Button onClick={() => modal?.show(<CreateEventModal />)}>
|
||||
|
@ -35,10 +35,12 @@ export default function Kind3745(props: Event) {
|
||||
["#e"]: [id],
|
||||
});
|
||||
if (directMessageEvent) {
|
||||
console.log("Found DM", directMessageEvent);
|
||||
await directMessageEvent.decrypt(
|
||||
new NDKUser({ hexpubkey: pubkey }),
|
||||
ndk?.signer,
|
||||
ndk!.signer,
|
||||
);
|
||||
console.log("Decryped DM", directMessageEvent);
|
||||
const passphrase = directMessageEvent.content;
|
||||
if (!passphrase) {
|
||||
setError("Unable to parse event");
|
||||
|
@ -5,6 +5,7 @@ import { getTagValues } from "./utils";
|
||||
import { sha256 as SHA256 } from "@noble/hashes/sha256";
|
||||
import { bytesToHex } from "@noble/hashes/utils";
|
||||
import crypto from "crypto";
|
||||
import { Buffer } from "buffer";
|
||||
|
||||
export enum Kind {
|
||||
Metadata = 0,
|
||||
@ -118,8 +119,8 @@ export function encryptMessage(message: string, password: string) {
|
||||
}
|
||||
}
|
||||
// Function to decrypt a hashed message using a passphrase
|
||||
// Function to decrypt a hashed message using a passphrase
|
||||
export function decryptMessage(encryptedMessage: string, password: string) {
|
||||
console.log("Attemping decrypto", encryptedMessage, "with", password);
|
||||
try {
|
||||
const buffer = create32ByteBuffer(password);
|
||||
// Extract IV from the received message
|
||||
@ -127,19 +128,11 @@ export function decryptMessage(encryptedMessage: string, password: string) {
|
||||
if (!ivBase64) {
|
||||
return;
|
||||
}
|
||||
|
||||
const iv = Buffer.from(ivBase64, "base64");
|
||||
|
||||
const encryptedText = Buffer.from(encryptedMessage, "base64");
|
||||
console.log("at bugger");
|
||||
const decipher = crypto.createDecipheriv("aes-256-cbc", buffer, iv);
|
||||
console.log("at decipher");
|
||||
|
||||
const decrypted = decipher.update(encryptedText);
|
||||
|
||||
const toReturn = Buffer.concat([decrypted, decipher.final()]).toString();
|
||||
console.log("toReturn", toReturn);
|
||||
return toReturn;
|
||||
return Buffer.concat([decrypted, decipher.final()]).toString();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
|
@ -30,6 +30,7 @@
|
||||
"@radix-ui/react-tooltip": "^1.0.7",
|
||||
"@tailwindcss/container-queries": "^0.1.1",
|
||||
"aws-sdk": "^2.1475.0",
|
||||
"buffer": "^6.0.3",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"clsx": "^2.0.0",
|
||||
"cmdk": "^0.2.0",
|
||||
|
Loading…
x
Reference in New Issue
Block a user