Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

CryptoKey

继承: Resource < RefCounted < Object

加密密钥(RSA)。

描述

CryptoKey 类表示加密密钥。密钥可以像其他任何 Resource 一样进行加载和保存。

密钥可以通过 Crypto.generate_self_signed_certificate 生成自签名的 X509Certificate,并可作为 StreamPeerTLS.accept_stream 中相应的证书的私钥。

教程

方法

bool

is_public_only ( ) const

Error

load ( String path, bool public_only=false )

Error

load_from_string ( String string_key, bool public_only=false )

Error

save ( String path, bool public_only=false )

String

save_to_string ( bool public_only=false )


方法说明

bool is_public_only ( ) const

如果该 CryptoKey 仅具有公钥部分,没有私钥部分,则返回 true


Error load ( String path, bool public_only=false )

从路径 path 加载密钥。如果 public_onlytrue,将只加载公钥。

注意:如果 public_onlytrue,则 path 应该是“*.pub”文件,否则是“*.key”文件。


Error load_from_string ( String string_key, bool public_only=false )

从给定的 string_key 加载密钥。如果 public_onlytrue,则仅会加载公钥。


Error save ( String path, bool public_only=false )

将密钥保存到给定的路径 path。如果 public_onlytrue,则只会保存公钥。

注意:如果 public_onlytrue,则 path 应该是“*.pub”文件,否则是“*.key”文件。


String save_to_string ( bool public_only=false )

返回包含 PEM 格式的密钥的字符串。如果 public_onlytrue,则仅包含公钥。