UNPKG

@synotech/utils

Version:

a collection of utilities for internal use

18 lines (16 loc) 557 B
/** * This function returns a public key string without the header and footer * @module publicKeyGetString * @param {string} key - a stringified object in string format * @return {string} {string} a public key string without the header and footer * @example * * publicKeyGetString('-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA) * */ export const publicKeyGetString = (key: string | any): any => { return key .replace(/-----BEGIN PUBLIC KEY-----|-----END PUBLIC KEY-----/g, '') .replace(/\\n/g, '\n') .trim(); };