.. java:import:: org.json JSONObject Key === .. java:package:: com.idopte.scmapi :noindex: .. java:type:: public abstract class Key extends TokenObject Abstract class describes a key object. Inherits from \ :java:ref:`TokenObject`\ . \ **API Changes (since 6.23.44.2)**\ The mobile SDK API has evolved to support different key types: \ :java:ref:`PrivateKey`\ and \ :java:ref:`PublicKey`\ are now abstract classes. Subclasses: .. * \ :java:ref:`PrivateKeyRSA`\ and \ :java:ref:`PrivateKeyEC`\ * \ :java:ref:`PublicKeyRSA`\ and \ :java:ref:`PublicKeyEC`\ Methods specific to a particular key type have been moved into these concrete classes. For example: .. * \ :java:ref:`PrivateKeyRSA.getModulus()`\ → only available for RSA Keys * \ :java:ref:`PublicKeyEC.getW()`\ → only available for \ :java:ref:`PublicKeyEC`\ This change introduces some backward compatibility issues: to use these methods, you must cast the key to the appropriate class. \ **Example**\ .. parsed-literal:: PrivateKey privateKey; if (privateKey instanceof PrivateKeyRSA) { PrivateKeyRSA rsaPrivateKey = (PrivateKeyRSA) privateKey; BigInteger modulus = rsaPrivateKey.getModulus(); } On the other hand, methods common to all private keys (\ :java:ref:`PrivateKey.sign()`\ , \ :java:ref:`PrivateKey.decrypt()`\ , \ :java:ref:`PrivateKey.hashAndSign()`\ , \ :java:ref:`PrivateKey.getPssParameters()`\ , \ :java:ref:`PrivateKey.isPartialHash()`\ ) remain defined in \ :java:ref:`PrivateKey`\ . Their usage has not changed. Methods ------- getAlgorithmName ^^^^^^^^^^^^^^^^ .. java:method:: public String getAlgorithmName() :outertype: Key Gets the algorithm of the key. The possible values are ``"RSA"`` or ``"ECDSA"``. :return: the algorithm of the key. getKeyLength ^^^^^^^^^^^^ .. java:method:: public int getKeyLength() :outertype: Key Gets the key length, in bits. :return: the key length.