• Generate an RSA key pair. Supports 1024, 2048, 3072, and 4096 bits.

    The larger the key bit, the higher the security, the longer the data content that can be encrypted, and the longer the encryption time. It is recommended that the bit be set to a value greater than or equal to 2048.

    Parameters

    • bits: number

      Number of key bits

    Returns RSAKey

    Example


    import * as crypto from 'crypto';
    import * as buffer from 'buffer';

    let rsakey = crypto.generateKey(2048);

    console.log(rsakey.privateKey.toString());

    console.log('\n');

    console.log(rsakey.publicKey.toString());