MCPcopy Index your code
hub / github.com/travist/jsencrypt / getKey

Method getKey

src/JSEncrypt.ts:205–222  ·  view source on GitHub ↗

* Getter for the current JSEncryptRSAKey object. If it doesn't exists a new object * will be created and returned * @param {callback} [cb] the callback to be called if we want the key to be generated * in an async fashion * @returns {JSEncryptRSAKey} the JSEncryptRSAKey object

(cb?: () => void)

Source from the content-addressed store, hash-verified

203 * @public
204 */
205 public getKey(cb?: () => void) {
206 // Only create new if it does not exist.
207 if (!this.key) {
208 // Get a new private key.
209 this.key = new JSEncryptRSAKey();
210 if (cb && {}.toString.call(cb) === "[object Function]") {
211 this.key.generateAsync(
212 this.default_key_size,
213 this.default_public_exponent,
214 cb,
215 );
216 return;
217 }
218 // Generate the key.
219 this.key.generate(this.default_key_size, this.default_public_exponent);
220 }
221 return this.key;
222 }
223
224 /**
225 * Returns the pem encoded representation of the private key

Callers 15

runExamplesTestsFunction · 0.95
runExamplesTestsFunction · 0.95
testNodeJSCompatibilityFunction · 0.95
decryptMethod · 0.95
encryptMethod · 0.95
encryptOAEPMethod · 0.95
signMethod · 0.95
verifyMethod · 0.95
getPrivateKeyMethod · 0.95
getPrivateKeyB64Method · 0.95
getPublicKeyMethod · 0.95
getPublicKeyB64Method · 0.95

Calls 2

generateAsyncMethod · 0.80
generateMethod · 0.80

Tested by

no test coverage detected