Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
crypto functions for fognet and the web
phog uses the Web Crypto API and base 58 encoding
open test.html in any browser to test
const configs = {
sign: {
algo: {name: 'ECDSA', namedCurve: 'P-256'},
usage: ['sign', 'verify'],
format: {public:'spki', private:'pkcs8'}
},
derive: {
algo: {name:'ECDH', namedCurve:'P-256'},
usage: ['deriveKey'],
format: {public:'spki', private:'pkcs8'}
},
encrypt: {
algo: {name:'AES-GCM', length: 256},
usage: ['encrypt', 'decrypt'],
format: {public:'raw', private:'raw'},
ivFunc: () => window.crypto.getRandomValues(new Uint8Array(12))
}
}
Generate a key (returns a CryptoKey pair)
const key = await phog.keyGen(phog.configs.sign) // for signing
const key = await phog.keyGen(phog.configs.derive) // for deriving shared keys
// returns { publicKey:CryptoKey{}, privateKey:CryptoKey{} }
Sign some text (returns base58-encoded signature string)
const sig = await phog.sign(txt, key.privateKey)
Verify a signature (returns a bool)
const verified = await phog.verify(txt, sig, importedPubKey)
Derive a shared symmetric key from your private key and another person's public key. (returns a CryptoKey)
const secret = await phog.deriveKey(key.privateKey, key.publicKey)
Symmetrically encrypt some data (returns a base58-encoded string)
const encrypted = await phog.encrypt(txt, secret)
Decrypt some data (returns a string)
const decrypted = await phog.decrypt(encrypted, secret)
Export a public key to base58:
const keyString = await phog.exportKey(key.publicKey, phog.configs.sign)
To export a private key, you must specify 'private' as the last argument:
const keyString = await phog.exportKey(key.privateKey, phog.configs.sign, 'private')
Import a base58-encoded public key (returns a CryptoKey)
const key = await phog.importKey(keyString, phog.configs.sign)
FAQs
Dead simple crypto module for Fognet
We found that phog 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
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.