PHP 8.4.2 Released!

rnp_ffi_set_pass_provider

(PECL rnp >= 0.1.1)

rnp_ffi_set_pass_providerSet password provider callback function

Beschreibung

rnp_ffi_set_pass_provider(RnpFFI $ffi, callable $password_callback): bool

Sets password provider function. This function can ask for the password on a standard input (if PHP script is executed in a command line environment), display GUI dialog or provide password in any other possible ways. Requested passwords are used to encrypt or decrypt secret keys or perform symmetric encryption/decryption operations.

Parameter-Liste

ffi

Das von rnp_ffi_create zurückgegebene FFI-Objekt.

password_callback

The function that is to be called for every password request. It has the following signature:

password_callback(string $key_fp, string $pgp_context, string &$password): bool
  • $key_fp - The key fingerprint, if any. Can be empty.
  • $pgp_context - String describing why the key is being requested.
  • $password - Password string reference where provided password should be stored to.
Callback function should return true if password was successfully setBei einem Fehler wird false zurückgegeben..

Rückgabewerte

Returns true on successBei einem Fehler wird false zurückgegeben..

Beispiele

Beispiel #1 simple callback function example

<?php
function password_callback(string $key_fp, string $pgp_context, string &$password)
{
$password = "password";

return
true;
}

$ffi = rnp_ffi_create('GPG', 'GPG');

rnp_ffi_set_pass_provider($ffi, 'password_callback');

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top