smartcrypto/ts/smartcrypto.classes.publickey.ts

25 lines
689 B
TypeScript
Raw Permalink Normal View History

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 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
}