[Crypto] Expose OS.get_entropy
This commit is contained in:
parent
8c70c18132
commit
ae7045f67e
|
@ -194,6 +194,14 @@ void ResourceSaver::_bind_methods() {
|
||||||
|
|
||||||
////// OS //////
|
////// OS //////
|
||||||
|
|
||||||
|
PackedByteArray OS::get_entropy(int p_bytes) {
|
||||||
|
PackedByteArray pba;
|
||||||
|
pba.resize(p_bytes);
|
||||||
|
Error err = ::OS::get_singleton()->get_entropy(pba.ptrw(), p_bytes);
|
||||||
|
ERR_FAIL_COND_V(err != OK, PackedByteArray());
|
||||||
|
return pba;
|
||||||
|
}
|
||||||
|
|
||||||
String OS::get_system_ca_certificates() {
|
String OS::get_system_ca_certificates() {
|
||||||
return ::OS::get_singleton()->get_system_ca_certificates();
|
return ::OS::get_singleton()->get_system_ca_certificates();
|
||||||
}
|
}
|
||||||
|
@ -577,6 +585,7 @@ String OS::get_unique_id() const {
|
||||||
OS *OS::singleton = nullptr;
|
OS *OS::singleton = nullptr;
|
||||||
|
|
||||||
void OS::_bind_methods() {
|
void OS::_bind_methods() {
|
||||||
|
ClassDB::bind_method(D_METHOD("get_entropy", "size"), &OS::get_entropy);
|
||||||
ClassDB::bind_method(D_METHOD("get_system_ca_certificates"), &OS::get_system_ca_certificates);
|
ClassDB::bind_method(D_METHOD("get_system_ca_certificates"), &OS::get_system_ca_certificates);
|
||||||
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &OS::get_connected_midi_inputs);
|
ClassDB::bind_method(D_METHOD("get_connected_midi_inputs"), &OS::get_connected_midi_inputs);
|
||||||
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &OS::open_midi_inputs);
|
ClassDB::bind_method(D_METHOD("open_midi_inputs"), &OS::open_midi_inputs);
|
||||||
|
|
|
@ -134,6 +134,7 @@ public:
|
||||||
RENDERING_DRIVER_D3D12,
|
RENDERING_DRIVER_D3D12,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PackedByteArray get_entropy(int p_bytes);
|
||||||
String get_system_ca_certificates();
|
String get_system_ca_certificates();
|
||||||
|
|
||||||
virtual PackedStringArray get_connected_midi_inputs();
|
virtual PackedStringArray get_connected_midi_inputs();
|
||||||
|
|
|
@ -262,6 +262,14 @@
|
||||||
[b]Note:[/b] This method is not supported on the Web platform. It returns an empty string.
|
[b]Note:[/b] This method is not supported on the Web platform. It returns an empty string.
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_entropy">
|
||||||
|
<return type="PackedByteArray" />
|
||||||
|
<param index="0" name="size" type="int" />
|
||||||
|
<description>
|
||||||
|
Generates a [PackedByteArray] of cryptographically secure random bytes with given [param size].
|
||||||
|
[b]Note:[/b] Generating large quantities of bytes using this method can result in locking and entropy of lower quality on most platforms. Using [method Crypto.generate_random_bytes] is preferred in most cases.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_environment" qualifiers="const">
|
<method name="get_environment" qualifiers="const">
|
||||||
<return type="String" />
|
<return type="String" />
|
||||||
<param index="0" name="variable" type="String" />
|
<param index="0" name="variable" type="String" />
|
||||||
|
|
Loading…
Reference in New Issue