title: How can I convert privateKey which is stored as binary into base64 using nodejs?
body: <p>Have a certificate and privateKey in the ORACLE DB as a separate columns. Both are saved as a binary in the respective columns. I want to convert it into base64 encoded and then to a PEM.</p>
  <p>I tried the following in Nodejs but not working as expected</p>
  <pre><code>Buffer.from(certificate).toString('base64')
  </code></pre>
  <p><strong>DB Value:</strong> <em>Pasted only part of the content</em></p>
  <pre><code>�\r\u0001\u0001\r\u0005\u0000\u0003�\u0002\u0001\u0000[�`E��)\u0013�Zk�jĆ\u0003#�\u0018У�l�\r6-��f���;\rݺ\u0013\u0004Y)�!�\rX�O�\u0002�Ib���\u0014x,���T*\u0010#@���O���\b���_�I\u0003�*3f\u0002ъ]������uP�eb\u0005q�WU\u0019'�9\u0002��ð�\u001a���t[fdJ{m�\u001a��|�/ڬ@I�x�NU�����oBV1M0�)�j�I�.��\u0001�&gt;{���T.�ƭ\&quot;���T��,���QI\u000b\u0010b�/X&gt;��q�aq\u000b'\nF�=]�\u0017�ݘ�\u0010�\u0013\u0016�}��J&amp;]\u0007i��7xW�.���Ӎ��֎{\u0007��\\�6#t�\u0015��\u0012�T4�\u001a�/\u0004�R\u0002}O\u000e\u0014�F�7���\u000b��W\u001b��A���*v���\u0016(_��m\u001f��\u001aCO�#�ګ\u0003\bX�9�e��*���tv:�\u0011k�_K�L��䂖9'$��0L:f\u001aec�\t��23e\u0014F%kX�Y�eD\u0012��H�C�\u0019gz�ۀd�\\���,,VR��1� 7ٶ\u000e����j�0���r�����\u000e{�\u0000���\u0002c��~*\u0013pY'�ݴ۾\u0006�\u001f���\u0000�::�BŢ��S��п�l[Cf�!Je�$;���\u0002�\u0019Ps������#���6\u001f�?ֹ�6
  </code></pre>
  <p><strong>After conversion:</strong> <em>Pasted only part of the content</em></p>
  <p>TnLvv71077+9W++/vSbvv700ae+/ve+/ve+/vV0ufe+/ve+/ve+/ve+/vU0LQnTvv70R77+9EmMI77+9Ye+/ve+/vXLKsHxI77+9Y++/ve+/vRfQuEUi77+9b3Xvv70Z77+9XDTvv73vv73vv73vv71n77+9Z++/ve+/ve+/ve+/vUvvv719NQQe77+9fQLvv73vv70A77+9XVBCTGDvv70+cO+/ve+/ve+/ve+/vXjvv70ERzHvv70PWVdv77+9fyAZ77+977+9de+/ve+/vXNb77+977+9MnHvv73vv71kdF0377+977+977+977+977+977+9du+/ve+/ve+/vUXvv70u77+9CSbvv71EQe+/vVMST++/ve+/ve+/vT3vv71Axp7vv73KpG7vv71wP++/vWfvv73vv711aTPvv70bAB5T77+9OABQP++/ve+/vRzvv70S77+9Nu+/vT9py54VQGjvv73vv73vv71u77+9Au+/vc2ZPA==</p>