Skip to content

Conversation

@tdrz
Copy link
Collaborator

@tdrz tdrz commented Dec 11, 2025

No description provided.

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

github-actions bot commented Dec 11, 2025

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@github-actions
Copy link
Contributor

@tdrz tdrz marked this pull request as ready for review December 16, 2025 16:12
@tdrz tdrz requested a review from samwillis December 16, 2025 16:12
@github-actions
Copy link
Contributor

@tdrz tdrz changed the title pgcrypto retake pgcrypto Dec 17, 2025
Copy link
Collaborator

@samwillis samwillis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines +99 to +128
it('pgp_pub_encrypt and pgp_pub_decrypt', async () => {
const pg = new PGlite({
extensions: {
pgcrypto,
},
})

await pg.exec('CREATE EXTENSION IF NOT EXISTS pgcrypto;')

const { privateKey, publicKey } = await openpgp.generateKey({
type: 'rsa',
rsaBits: 2048,
userIDs: [{ name: 'PGlite', email: '[email protected]' }],
passphrase: '',
})

const toEncrypt = 'PGlite@$#%!^$&*WQFgjqPkVERewfreg094340f1012-='

const e2 = await pg.exec(
`
WITH encrypted AS (
SELECT pgp_pub_encrypt('${toEncrypt}', dearmor('${publicKey}')) AS encrypted
)
SELECT
pgp_pub_decrypt(encrypted, dearmor('${privateKey}')) as decrypted_output
FROM encrypted;
`,
)
expect(e2[0].rows[0].decrypted_output, toEncrypt)
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect test!

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Jan 6, 2026

@tdrz tdrz merged commit 45bff97 into main Jan 6, 2026
23 of 24 checks passed
@tdrz tdrz deleted the tdrz/fe-pgcrypto branch January 6, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants