2022-10-23 21:53:34 +00:00
|
|
|
import * as plugins from './smartcrypto.plugins.js';
|
2019-10-01 13:27:21 +00:00
|
|
|
|
|
|
|
export class PrivateKey {
|
|
|
|
// STATIC
|
|
|
|
public static createFromPrivateKey(pemString: string) {
|
|
|
|
const privateKey = plugins.nodeForge.pki.privateKeyFromPem(pemString);
|
|
|
|
return new PrivateKey(privateKey);
|
|
|
|
}
|
|
|
|
|
2019-10-01 17:41:34 +00:00
|
|
|
public static fromPemString(pemString: string) {
|
|
|
|
return new PrivateKey(plugins.nodeForge.pki.privateKeyFromPem(pemString));
|
|
|
|
}
|
|
|
|
|
2019-10-01 13:27:21 +00:00
|
|
|
// 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);
|
|
|
|
}
|
|
|
|
}
|