smartcrypto/ts/smartcrypto.classes.publickey.ts

25 lines
686 B
TypeScript
Raw Permalink Normal View History

2019-10-01 13:27:21 +00:00
import * as plugins from './smartcrypto.plugins';
export class PublicKey {
// STATIC
public static createFromPrivateKey(pemString: string) {
const privateKey = plugins.nodeForge.pki.publicKeyFromPem(pemString);
return new PublicKey(privateKey);
}
2019-10-01 17:41:34 +00:00
public static fromPemString(pemString: string) {
return new PublicKey(plugins.nodeForge.pki.publicKeyFromPem(pemString));
}
2019-10-01 13:27:21 +00:00
// INSTANCE
public forgePublicKey: plugins.nodeForge.pki.PublicKey;
2019-10-01 17:28:50 +00:00
constructor(publicKeyArg: plugins.nodeForge.pki.PublicKey) {
2019-10-01 13:27:21 +00:00
this.forgePublicKey = publicKeyArg;
}
public toPemString(): string {
return plugins.nodeForge.pki.publicKeyToPem(this.forgePublicKey);
}
2019-10-01 17:28:50 +00:00
}