
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
@bryopsida/crypto
Advanced tools
A crypto library utilizing @bryopsida/key-store to protect data using data encryption keys
A library to faciliate using data encryption keys as well as do some light encryption/decryption.
import { randomBytes, randomUUID } from 'crypto'
import { tmpdir } from 'os'
import { FileKeyStore, IKeyStore } from '@bryopsida/key-store'
import { IDataEncryptor, EncryptOpts, Crypto } from '../src/crypto'
import { writeFile } from 'fs/promises'
import { describe, expect, it, beforeEach } from '@jest/globals'
//setup a key store, in this case on the file system
const key = randomBytes(32)
const salt = randomBytes(16)
const context = randomBytes(32)
const masterKey = randomBytes(32).toString('base64')
const masterSalt = randomBytes(16).toString('base64')
const masterKeyFile = randomUUID()
const masterSaltFile = randomUUID()
const storeDir = tmpdir()
const keyStoreDir = randomUUID()
await writeFile(`${storeDir}/${masterKeyFile}`, masterKey)
await writeFile(`${storeDir}/${masterSaltFile}`, masterSalt)
keyStore = new FileKeyStore(
`${storeDir}/${keyStoreDir}`,
() => Promise.resolve(key),
() => Promise.resolve(salt),
() => Promise.resolve(context)
)
// now we can make the crypto instance
crypto = new Crypto(
keyStore,
`${storeDir}/${masterKeyFile}`,
`${storeDir}/${masterSaltFile}`
)
// an example of encrypting to a encoded value and decrypting
it('can encrypt and decrypted encoded text', async () => {
const rootKeyId = await crypto.generateRootKey(32, 'encoded-test')
const dek = await crypto.generateDataEncKey(
32,
rootKeyId,
'encoded-test',
'dek'
)
const encryptedData = await crypto.encryptAndEncode({
plaintext: Buffer.from('test-data'),
keyId: dek,
rootKeyId,
rootKeyContext: 'encoded-test',
dekContext: 'dek',
context: Buffer.from('data-context'),
})
const plainText = (
await crypto.decryptEncoded(
encryptedData,
'encoded-test',
'dek',
'data-context'
)
).toString('utf8')
expect(plainText).toEqual('test-data')
})
FAQs
A crypto library utilizing @bryopsida/key-store to protect data using data encryption keys
We found that @bryopsida/crypto demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.