mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: generate key pair function
This commit is contained in:
1 parent
2a3429106c
commit
2cc348687a
2 files changed
+29
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import { generateKeyPairSync } from 'crypto'
|
||||
|
||||
type KeyPair = {
|
||||
privateKey: string
|
||||
publicKey: string
|
||||
}
|
||||
|
||||
export function generateKeyPair(): KeyPair {
|
||||
const { privateKey, publicKey } = generateKeyPairSync('ed25519', {
|
||||
publicKeyEncoding: {
|
||||
type: 'spki',
|
||||
format: 'pem',
|
||||
},
|
||||
privateKeyEncoding: {
|
||||
type: 'pkcs8',
|
||||
format: 'pem',
|
||||
},
|
||||
})
|
||||
return { privateKey, publicKey }
|
||||
}
|
||||
Reference in new issue
Block a user