{"id":13510285,"url":"https://github.com/juliangruber/keypair","last_synced_at":"2025-05-15T16:02:11.029Z","repository":{"id":8454205,"uuid":"10049193","full_name":"juliangruber/keypair","owner":"juliangruber","description":"Generate a RSA PEM key pair from pure JS","archived":false,"fork":false,"pushed_at":"2022-10-14T14:50:32.000Z","size":67,"stargazers_count":277,"open_issues_count":8,"forks_count":51,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-31T20:06:57.272Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/juliangruber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-05-14T07:03:34.000Z","updated_at":"2025-03-27T03:17:14.000Z","dependencies_parsed_at":"2022-09-07T03:40:32.877Z","dependency_job_id":null,"html_url":"https://github.com/juliangruber/keypair","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fkeypair","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fkeypair/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fkeypair/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/juliangruber%2Fkeypair/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/juliangruber","download_url":"https://codeload.github.com/juliangruber/keypair/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247730068,"owners_count":20986404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T02:01:32.025Z","updated_at":"2025-04-07T21:11:43.544Z","avatar_url":"https://github.com/juliangruber.png","language":"JavaScript","readme":"# keypair\n\nGenerate a RSA PEM key pair from pure JS\n\n[![Build Status](https://travis-ci.org/juliangruber/keypair.svg?branch=master)](https://travis-ci.org/juliangruber/keypair)\n[![downloads](https://img.shields.io/npm/dm/keypair.svg)](https://www.npmjs.org/package/keypair)\n\n[![browser support](https://ci.testling.com/juliangruber/keypair.png)](https://ci.testling.com/juliangruber/keypair)\n\n## Usage\n\n```js\nvar keypair = require('keypair');\n\nvar pair = keypair();\nconsole.log(pair);\n```\n\noutputs\n\n```\n$ node example.js\n{ public: '-----BEGIN RSA PUBLIC KEY-----\\r\\nMIGJAoGBAM3CosR73CBNcJsLv5E90NsFt6qN1uziQ484gbOoule8leXHFbyIzPQRozgEpSpi\\r\\nwhr6d2/c0CfZHEJ3m5tV0klxfjfM7oqjRMURnH/rmBjcETQ7qzIISZQ/iptJ3p7Gi78X5ZMh\\r\\nLNtDkUFU9WaGdiEb+SnC39wjErmJSfmGb7i1AgMBAAE=\\r\\n-----END RSA PUBLIC KEY-----\\n',\n  private: '-----BEGIN RSA PRIVATE KEY-----\\r\\nMIICXAIBAAKBgQDNwqLEe9wgTXCbC7+RPdDbBbeqjdbs4kOPOIGzqLpXvJXlxxW8iMz0EaM4\\r\\nBKUqYsIa+ndv3NAn2RxCd5ubVdJJcX43zO6Ko0TFEZx/65gY3BE0O6syCEmUP4qbSd6exou/\\r\\nF+WTISzbQ5FBVPVmhnYhG/kpwt/cIxK5iUn5hm+4tQIDAQABAoGBAI+8xiPoOrA+KMnG/T4j\\r\\nJsG6TsHQcDHvJi7o1IKC/hnIXha0atTX5AUkRRce95qSfvKFweXdJXSQ0JMGJyfuXgU6dI0T\\r\\ncseFRfewXAa/ssxAC+iUVR6KUMh1PE2wXLitfeI6JLvVtrBYswm2I7CtY0q8n5AGimHWVXJP\\r\\nLfGV7m0BAkEA+fqFt2LXbLtyg6wZyxMA/cnmt5Nt3U2dAu77MzFJvibANUNHE4HPLZxjGNXN\\r\\n+a6m0K6TD4kDdh5HfUYLWWRBYQJBANK3carmulBwqzcDBjsJ0YrIONBpCAsXxk8idXb8jL9a\\r\\nNIg15Wumm2enqqObahDHB5jnGOLmbasizvSVqypfM9UCQCQl8xIqy+YgURXzXCN+kwUgHinr\\r\\nutZms87Jyi+D8Br8NY0+Nlf+zHvXAomD2W5CsEK7C+8SLBr3k/TsnRWHJuECQHFE9RA2OP8W\\r\\noaLPuGCyFXaxzICThSRZYluVnWkZtxsBhW2W8z1b8PvWUE7kMy7TnkzeJS2LSnaNHoyxi7Ia\\r\\nPQUCQCwWU4U+v4lD7uYBw00Ga/xt+7+UqFPlPVdz1yyr4q24Zxaw0LgmuEvgU5dycq8N7Jxj\\r\\nTubX0MIRR+G9fmDBBl8=\\r\\n-----END RSA PRIVATE KEY-----\\n' }\n```\n\n## Performance\n\nPerformance greatly depends on the bit size of the generated private key. With 1024 bits you get a key in 0.5s-2s, with 2048 bits it takes 8s-20s, on the same machine. As this will block the event loop while generating the key,\nmake sure that's ok or to spawn a child process or run it inside a webworker.\n\n## Pro Tip: authorized_keys\n\n@maxogden found out how to use this module to create entries for the `authorized_keys` file:\n\n```js\nvar keypair = require('keypair');\nvar forge = require('node-forge');\n\nvar pair = keypair();\nvar publicKey = forge.pki.publicKeyFromPem(pair.public);\nvar ssh = forge.ssh.publicKeyToOpenSSH(publicKey, 'user@domain.tld');\nconsole.log(ssh);\n```\n\n## API\n\n### keypair([opts])\n\nGet an RSA PEM key pair.\n\n`opts` can be\n\n* `bits`: the size for the private key in bits. Default: **2048**.\n* `e`: the public exponent to use. Default: **65537**.\n\n## Installation\n\nWith [npm](http://npmjs.org) do\n\n```bash\n$ npm install keypair\n```\n\n## Kudos\n\nTo [digitalbazaar](https://github.com/digitalbazaar) for their\n[forge](https://github.com/digitalbazaar/forge) project, this library is merely a\nwrapper around some of forge's functions.\n\n## License\n\nBSD / GPL\n","funding_links":[],"categories":["JavaScript","others","crypto (加密)"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliangruber%2Fkeypair","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjuliangruber%2Fkeypair","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjuliangruber%2Fkeypair/lists"}