Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
CryptoKey
继承: Resource < RefCounted < Object
加密密钥(RSA 或椭圆曲线)。
描述
CryptoKey 类表示加密密钥。密钥可以像其他任何 Resource 一样进行加载和保存。
密钥可以通过 Crypto.generate_self_signed_certificate() 生成自签名的 X509Certificate,并可作为 StreamPeerTLS.accept_stream() 中相应的证书的私钥。
教程
方法
is_public_only() const |
|
load_from_string(string_key: String, public_only: bool = false) |
|
save_to_string(public_only: bool = false) |
方法说明
如果该 CryptoKey 仅具有公钥部分,没有私钥部分,则返回 true
。
Error load(path: String, public_only: bool = false) 🔗
从路径 path
加载密钥。如果 public_only
为 true
,将只加载公钥。
注意:如果 public_only
为 true
,则 path
应该是“*.pub”文件,否则是“*.key”文件。
Error load_from_string(string_key: String, public_only: bool = false) 🔗
从给定的 string_key
加载密钥。如果 public_only
为 true
,则仅会加载公钥。
Error save(path: String, public_only: bool = false) 🔗
将密钥保存到给定的路径 path
。如果 public_only
为 true
,则只会保存公钥。
注意:如果 public_only
为 true
,则 path
应该是“*.pub”文件,否则是“*.key”文件。
String save_to_string(public_only: bool = false) 🔗
返回包含 PEM 格式的密钥的字符串。如果 public_only
为 true
,则仅包含公钥。