Add setOptions to node-rsa class definition

This commit is contained in:
Christian Moniz
2018-03-19 15:59:55 -07:00
parent 9f4c751261
commit 5104d46ff7
2 changed files with 11 additions and 0 deletions

View File

@@ -1,6 +1,7 @@
// Type definitions for node-rsa 0.4
// Project: https://github.com/rzcoder/node-rsa
// Definitions by: Ali Taheri <https://github.com/alitaheri>
// Christian Moniz <https://github.com/xm>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
@@ -17,6 +18,11 @@ declare class NodeRSA {
*/
constructor(key: NodeRSA.Key, format?: NodeRSA.Format, options?: NodeRSA.Options);
/**
* Set and validate options for key instance.
*/
setOptions(options: NodeRSA.Options): void;
/**
* @param bits Key size in bits. 2048 by default.
* @param exponent public exponent. 65537 by default.

View File

@@ -2,6 +2,11 @@ import NodeRSA = require('node-rsa');
const key = new NodeRSA({ b: 512 });
key.setOptions({
encryptionScheme: 'pkcs1_oaep',
signingScheme: 'pkcs1'
});
const text = 'Hello RSA!';
const encrypted = key.encrypt(text, 'base64');
const decrypted = key.decrypt(encrypted, 'utf8');