fix(core): initial, support creation of rsa keypairs

This commit is contained in:
2019-10-01 14:22:21 +02:00
parent 70d7404b90
commit 44c2adf45d
6 changed files with 54 additions and 15 deletions

View File

@ -1,3 +1 @@
import * as plugins from './smartcrypto.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './smartcrypto.classes.smartcrypto';

View File

@ -0,0 +1,17 @@
import * as plugins from './smartcrypto.plugins';
export class Smartcrypto {
public static async createRSAKeyPair(): Promise<plugins.nodeForge.pki.KeyPair> {
const done = plugins.smartpromise.defer<plugins.nodeForge.pki.KeyPair>();
const rsa = plugins.nodeForge.pki.rsa;
rsa.generateKeyPair({bits: 2048, workers: 2}, (err, keypair) => {
if (err) {
console.log(err);
throw err;
}
done.resolve(keypair);
// keypair.privateKey, keypair.publicKey
});
return done.promise;
}
}

View File

@ -1,4 +1,13 @@
const removeme = {};
// @pushrocks scope
import * as smartpromise from '@pushrocks/smartpromise';
export {
removeme
}
smartpromise
};
// third party scope
import * as nodeForge from 'node-forge';
export {
nodeForge
};