Secret.Value¶
Fields¶
None
Methods¶
class |
|
class |
|
|
|
|
|
|
|
|
|
|
Details¶
- class Secret.Value¶
A value containing a secret
A
Secret.Value
contains a password or other secret value.Use [method`Value`.get] to get the actual secret data, such as a password. The secret data is not necessarily null-terminated, unless the content type is “text/plain”.
Each
Secret.Value
has a content type. For passwords, this istext/plain
. Use [method`Value`.get_content_type] to look at the content type.Secret.Value
is reference counted and immutable. The secret data is only freed when all references have been released via [method`Value`.unref].- classmethod new(secret, length, content_type)¶
- Parameters:
- Returns:
the new
Secret.Value
- Return type:
Create a
Secret.Value
for the secret data passed in.The secret data is copied into non-pageable ‘secure’ memory.
If the length is less than zero, then secret is assumed to be null-terminated.
- classmethod new_full(secret, length, content_type, destroy)¶
- Parameters:
secret (
str
) – the secret datalength (
int
) – the length of the datacontent_type (
str
) – the content type of the datadestroy (
GLib.DestroyNotify
) – function to call to free the secret data
- Returns:
the new
Secret.Value
- Return type:
Create a
Secret.Value
for the secret data passed in.The secret data is not copied, and will later be freed with the destroy function.
If the length is less than zero, then secret is assumed to be null-terminated.
- get()¶
- Returns:
the secret data
- Return type:
Get the secret data in the
Secret.Value
.The value is not necessarily null-terminated unless it was created with [ctor`Value`.new] or a null-terminated string was passed to [ctor`Value`.new_full].
- get_content_type()¶
- Returns:
the content type
- Return type:
Get the content type of the secret value, such as
text/plain
.
- get_text()¶
-
Get the secret data in the
Secret.Value
if it contains a textual value.The content type must be
text/plain
.
- ref()¶
- Returns:
the value
- Return type:
Add another reference to the
Secret.Value
.For each reference [method`Value`.unref] should be called to unreference the value.
- unref()¶
Unreference a
Secret.Value
.When the last reference is gone, then the value will be freed.
- unref_to_password(length)¶
- Parameters:
length (
int
) – the length of the secret- Returns:
a new password string stored in nonpageable memory which must be freed with [func`password_free`] when done
- length:
the length of the secret
- Return type:
Unreference a
Secret.Value
and steal the secret data inSecret.Value
as nonpageable memory.New in version 0.19.0.