How to use the generateKeyPair function from crypto

Find comprehensive JavaScript crypto.generateKeyPair code examples handpicked from public code repositorys.

50
51
52
53
54
55
56
57
58
59
  }
}

function genKeys() {
  return new Promise((resolve, reject) => {
    crypto.generateKeyPair(
      'rsa',
      {
        modulusLength: 2048,
      },
fork icon62
star icon243
watch icon17

+ 3 other calls in file

427
428
429
430
431
432
433
434
435
436
437
    })
}


const generateKeypair = () => {
    return new Promise((resolve, reject) => {
        crypto.generateKeyPair("rsa", {
            modulusLength: 4096,
            publicKeyEncoding: {
                type: "spki",
                format: "der"
fork icon24
star icon118
watch icon8

928
929
930
931
932
933
934
935
936
937
if(!forge.options.usePureJavaScript && !options.prng &&
  bits >= 256 && bits <= 16384 && (e === 0x10001 || e === 3)) {
  if(callback) {
    // try native async
    if(_detectNodeCrypto('generateKeyPair')) {
      return _crypto.generateKeyPair('rsa', {
        modulusLength: bits,
        publicExponent: e,
        publicKeyEncoding: {
          type: 'spki',
fork icon1
star icon0
watch icon0

17
18
19
20
21
22
23
24
25
26
27
28
const { generateKeyPair } = require('crypto');


{
  // This test makes sure deprecated options still work as intended


  generateKeyPair('rsa-pss', {
    modulusLength: 512,
    saltLength: 16,
    hash: 'sha256',
    mgf1Hash: 'sha256'
fork icon0
star icon0
watch icon0

131
132
133
134
135
136
137
138
139
140
141
142
};


const JWTKeyGen = async () => {


    return new Promise((resolve, rejects) => {
        crypto.generateKeyPair('rsa', {
            modulusLength: 4096,
            publicKeyEncoding: {
                type: 'pkcs1',
                format: 'pem'
fork icon0
star icon0
watch icon0