mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-11 03:27:47 +08:00
Add setOptions to node-rsa class definition
This commit is contained in:
6
types/node-rsa/index.d.ts
vendored
6
types/node-rsa/index.d.ts
vendored
@@ -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.
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user