Files
godot-docs-l10n/classes/zh_Hans/class_cryptokey.rst

126 lines
6.2 KiB
ReStructuredText
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

:github_url: hide
.. _class_CryptoKey:
CryptoKey
=========
**继承:** :ref:`Resource<class_Resource>` **<** :ref:`RefCounted<class_RefCounted>` **<** :ref:`Object<class_Object>`
加密密钥RSA 或椭圆曲线)。
.. rst-class:: classref-introduction-group
描述
----
CryptoKey 类表示加密密钥。密钥可以像其他任何 :ref:`Resource<class_Resource>` 一样进行加载和保存。
密钥可以通过 :ref:`Crypto.generate_self_signed_certificate()<class_Crypto_method_generate_self_signed_certificate>` 生成自签名的 :ref:`X509Certificate<class_X509Certificate>`\ ,并可作为 :ref:`StreamPeerTLS.accept_stream()<class_StreamPeerTLS_method_accept_stream>` 中相应的证书的私钥。
.. rst-class:: classref-introduction-group
教程
----
- :doc:`SSL 证书 <../tutorials/networking/ssl_certificates>`
.. rst-class:: classref-reftable-group
方法
----
.. table::
:widths: auto
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`bool<class_bool>` | :ref:`is_public_only<class_CryptoKey_method_is_public_only>`\ (\ ) |const| |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load<class_CryptoKey_method_load>`\ (\ path\: :ref:`String<class_String>`, public_only\: :ref:`bool<class_bool>` = false\ ) |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`load_from_string<class_CryptoKey_method_load_from_string>`\ (\ string_key\: :ref:`String<class_String>`, public_only\: :ref:`bool<class_bool>` = false\ ) |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`Error<enum_@GlobalScope_Error>` | :ref:`save<class_CryptoKey_method_save>`\ (\ path\: :ref:`String<class_String>`, public_only\: :ref:`bool<class_bool>` = false\ ) |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
| :ref:`String<class_String>` | :ref:`save_to_string<class_CryptoKey_method_save_to_string>`\ (\ public_only\: :ref:`bool<class_bool>` = false\ ) |
+---------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------+
.. rst-class:: classref-section-separator
----
.. rst-class:: classref-descriptions-group
方法说明
--------
.. _class_CryptoKey_method_is_public_only:
.. rst-class:: classref-method
:ref:`bool<class_bool>` **is_public_only**\ (\ ) |const| :ref:`🔗<class_CryptoKey_method_is_public_only>`
如果该 CryptoKey 仅具有公钥部分,没有私钥部分,则返回 ``true``\ 。
.. rst-class:: classref-item-separator
----
.. _class_CryptoKey_method_load:
.. rst-class:: classref-method
:ref:`Error<enum_@GlobalScope_Error>` **load**\ (\ path\: :ref:`String<class_String>`, public_only\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_CryptoKey_method_load>`
从路径 ``path`` 加载密钥。如果 ``public_only````true``\ ,将只加载公钥。
\ **注意:**\ 如果 ``public_only````true``\ ,则 ``path`` 应该是“\*.pub”文件否则是“\*.key”文件。
.. rst-class:: classref-item-separator
----
.. _class_CryptoKey_method_load_from_string:
.. rst-class:: classref-method
:ref:`Error<enum_@GlobalScope_Error>` **load_from_string**\ (\ string_key\: :ref:`String<class_String>`, public_only\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_CryptoKey_method_load_from_string>`
从给定的 ``string_key`` 加载密钥。如果 ``public_only````true``\ ,则仅会加载公钥。
.. rst-class:: classref-item-separator
----
.. _class_CryptoKey_method_save:
.. rst-class:: classref-method
:ref:`Error<enum_@GlobalScope_Error>` **save**\ (\ path\: :ref:`String<class_String>`, public_only\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_CryptoKey_method_save>`
将密钥保存到给定的路径 ``path``\ 。如果 ``public_only````true``\ ,则只会保存公钥。
\ **注意:**\ 如果 ``public_only````true``\ ,则 ``path`` 应该是“\*.pub”文件否则是“\*.key”文件。
.. rst-class:: classref-item-separator
----
.. _class_CryptoKey_method_save_to_string:
.. rst-class:: classref-method
:ref:`String<class_String>` **save_to_string**\ (\ public_only\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_CryptoKey_method_save_to_string>`
返回包含 PEM 格式的密钥的字符串。如果 ``public_only````true``\ ,则仅包含公钥。
.. |virtual| replace:: :abbr:`virtual (本方法通常需要用户覆盖才能生效。)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (本方法无副作用,不会修改该实例的任何成员变量。)`
.. |vararg| replace:: :abbr:`vararg (本方法除了能接受在此处描述的参数外,还能够继续接受任意数量的参数。)`
.. |constructor| replace:: :abbr:`constructor (本方法用于构造某个类型。)`
.. |static| replace:: :abbr:`static (调用本方法无需实例,可直接使用类名进行调用。)`
.. |operator| replace:: :abbr:`operator (本方法描述的是使用本类型作为左操作数的有效运算符。)`
.. |bitfield| replace:: :abbr:`BitField (这个值是由下列位标志构成位掩码的整数。)`
.. |void| replace:: :abbr:`void (无返回值。)`