How to use the @casual-simulation/crypto.formatPublicPEMKey function in @casual-simulation/crypto

To help you get started, we’ve selected a few @casual-simulation/crypto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github casual-simulation / aux / src / crypto-browser / BrowserSigningCryptoImpl.ts View on Github external
async exportKey(key: SigningCryptoKey): Promise {
        let buffer: ArrayBuffer;
        if (key instanceof BrowserPublicCryptoKey) {
            buffer = await crypto.subtle.exportKey('spki', key.publicKey);
            return formatPublicPEMKey(buffer);
        } else if (key instanceof BrowserPrivateCryptoKey) {
            buffer = await crypto.subtle.exportKey('pkcs8', key.privateKey);
            return formatPrivatePEMKey(buffer);
        }
        throw this._unknownKey();
    }