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
A cryptographic key (RSA or elliptic-curve).
說明
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,則僅包含公開金鑰。