smartcrypto/ts/smartcrypto.classes.privatekey.ts

21 lines
564 B
TypeScript
Raw Normal View History

2019-10-01 13:27:21 +00:00
import * as plugins from './smartcrypto.plugins';
export class PrivateKey {
// STATIC
public static createFromPrivateKey(pemString: string) {
const privateKey = plugins.nodeForge.pki.privateKeyFromPem(pemString);
return new PrivateKey(privateKey);
}
// INSTANCE
public forgePrivateKey: plugins.nodeForge.pki.PrivateKey;
constructor(privateKeyArg: plugins.nodeForge.pki.PrivateKey) {
this.forgePrivateKey = privateKeyArg;
}
public toPemString(): string {
return plugins.nodeForge.pki.privateKeyToPem(this.forgePrivateKey);
}
}