next.js/test/e2e/app-dir/cache-components/app/node-crypto/generate-key-pair-sync/cached/page.tsx
page.tsx41 lines940 B
import crypto from 'node:crypto'

import { SentinelValue } from '../../../getSentinelValue'

export default async function Page() {
  const first = await getGeneratedKeyPair(1)
  const second = await getGeneratedKeyPair(2)
  return (
    <div>
      <dl>
        <dt>
          [first] require('node:crypto').generateKeyPairSync(type, options)
        </dt>
        <dd id="first">{first.publicKey}</dd>
        <dt>
          [second] require('node:crypto').generateKeyPairSync(type, options)
        </dt>
        <dd id="second">{second.publicKey}</dd>
      </dl>
      <span id="page">
        <SentinelValue />
      </span>
    </div>
  )
}

async function getGeneratedKeyPair(_nonce: number) {
  'use cache'
  return crypto.generateKeyPairSync('rsa', {
    modulusLength: 512,
    publicKeyEncoding: {
      type: 'spki',
      format: 'pem',
    },
    privateKeyEncoding: {
      type: 'pkcs8',
      format: 'pem',
    },
  })
}
Quest for Codev2.0.0
/
SIGN IN