src/Common/Signer.php
public function convertKey($key, $type)
    {
        $lines = [];

        if ($type == self::KEY_TYPE_PUBLIC) {
            $lines[] = '-----BEGIN PUBLIC KEY-----';
        } else {
            $lines[] = '-----BEGIN RSA PRIVATE KEY-----';
        }

        for ($i = 0; $i < strlen($key); $i += 64) {
            $lines[] = trim(substr($key, $i, 64));
        }

        if ($type == self::KEY_TYPE_PUBLIC) {
            $lines[] = '-----END PUBLIC KEY-----';
        } else {
            $lines[] = '-----END RSA PRIVATE KEY-----';
        }

        return implode("\n", $lines);
    }
public function convertKey($key, $type)
    {
        $lines = [];

        if ($type == self::KEY_TYPE_PUBLIC) {
            $lines[] = '-----BEGIN PUBLIC KEY-----';
        } else {
            $lines[] = '-----BEGIN RSA PRIVATE KEY-----';
        }

        for ($i = 0; $i < strlen($key); $i += 64) {
            $lines[] = trim(substr($key, $i, 64));
        }

        if ($type == self::KEY_TYPE_PUBLIC) {
            $lines[] = '-----END PUBLIC KEY-----';
        } else {
            $lines[] = '-----END RSA PRIVATE KEY-----';
        }

        return implode("\n", $lines);
    }
public function convertKey ( $ key , $ type ) { $ lines = [ ] ; if ( $ type == self :: KEY_TYPE_PUBLIC ) { $ lines [ ] = '-----BEGIN PUBLIC KEY-----' ; } else { $ lines [ ] = '-----BEGIN RSA PRIVATE KEY-----' ; } for ( $ i = 0 ; $ i < strlen ( $ key ) ; $ i += 64 ) { $ lines [ ] = trim ( substr ( $ key , $ i , 64 ) ) ; } if ( $ type == self :: KEY_TYPE_PUBLIC ) { $ lines [ ] = '-----END PUBLIC KEY-----' ; } else { $ lines [ ] = '-----END RSA PRIVATE KEY-----' ; } return implode ( "\n" , $ lines ) ; }
Convert one line key to standard format

@param $key
@param $type

@return string
Convert one line key to standard format