Unhelpful error message when trying to get a private key from a public one
Author: pmaxhoganCreated Apr 20, 2017Updated Jun 12, 2026
var private = new JSEncrypt();
var public = new JSEncrypt();
public.setPrivateKey(decrypt.getPublicKey());
public.getPrivateKey();results in

A weird error message for "it is impossible to get a private key from a public one". This would be better:

Just run:
throw new TypeError("Cannot get a private key from a public one.");Source: travist/jsencrypt