:github_url: hide .. DO NOT EDIT THIS FILE!!! .. Generated automatically from Godot engine sources. .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py. .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/CryptoKey.xml. .. _class_CryptoKey: CryptoKey ========= **Inherits:** :ref:`Resource` **<** :ref:`RefCounted` **<** :ref:`Object` A cryptographic key (RSA or elliptic-curve). .. rst-class:: classref-introduction-group Description ----------- The CryptoKey class represents a cryptographic key. Keys can be loaded and saved like any other :ref:`Resource`. They can be used to generate a self-signed :ref:`X509Certificate` via :ref:`Crypto.generate_self_signed_certificate()` and as private key in :ref:`StreamPeerTLS.accept_stream()` along with the appropriate certificate. .. rst-class:: classref-introduction-group Tutorials --------- - :doc:`SSL certificates <../tutorials/networking/ssl_certificates>` .. rst-class:: classref-reftable-group Methods ------- .. table:: :widths: auto +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`bool` | :ref:`is_public_only`\ (\ ) |const| | +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`load`\ (\ path\: :ref:`String`, public_only\: :ref:`bool` = false\ ) | +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`load_from_string`\ (\ string_key\: :ref:`String`, public_only\: :ref:`bool` = false\ ) | +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`Error` | :ref:`save`\ (\ path\: :ref:`String`, public_only\: :ref:`bool` = false\ ) | +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`save_to_string`\ (\ public_only\: :ref:`bool` = false\ ) | +---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group Method Descriptions ------------------- .. _class_CryptoKey_method_is_public_only: .. rst-class:: classref-method :ref:`bool` **is_public_only**\ (\ ) |const| :ref:`🔗` Returns ``true`` if this CryptoKey only has the public part, and not the private one. .. rst-class:: classref-item-separator ---- .. _class_CryptoKey_method_load: .. rst-class:: classref-method :ref:`Error` **load**\ (\ path\: :ref:`String`, public_only\: :ref:`bool` = false\ ) :ref:`🔗` Loads a key from ``path``. If ``public_only`` is ``true``, only the public key will be loaded. \ **Note:** ``path`` should be a "\*.pub" file if ``public_only`` is ``true``, a "\*.key" file otherwise. .. rst-class:: classref-item-separator ---- .. _class_CryptoKey_method_load_from_string: .. rst-class:: classref-method :ref:`Error` **load_from_string**\ (\ string_key\: :ref:`String`, public_only\: :ref:`bool` = false\ ) :ref:`🔗` Loads a key from the given ``string_key``. If ``public_only`` is ``true``, only the public key will be loaded. .. rst-class:: classref-item-separator ---- .. _class_CryptoKey_method_save: .. rst-class:: classref-method :ref:`Error` **save**\ (\ path\: :ref:`String`, public_only\: :ref:`bool` = false\ ) :ref:`🔗` Saves a key to the given ``path``. If ``public_only`` is ``true``, only the public key will be saved. \ **Note:** ``path`` should be a "\*.pub" file if ``public_only`` is ``true``, a "\*.key" file otherwise. .. rst-class:: classref-item-separator ---- .. _class_CryptoKey_method_save_to_string: .. rst-class:: classref-method :ref:`String` **save_to_string**\ (\ public_only\: :ref:`bool` = false\ ) :ref:`🔗` Returns a string containing the key in PEM format. If ``public_only`` is ``true``, only the public key will be included. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)` .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)` .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)` .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)` .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)` .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)` .. |void| replace:: :abbr:`void (No return value.)`