Lista de Clases
- App\Middleware\Cors
- App\Middleware\Auth
- App\Middleware\Env
- AppMin
- Application
- Route
- Data\Database
- Data\Db2Database
- Data\OdbcDatabase
- Data\Validator
- Data\KeyValue\SqliteStorage
- Data\Log\FileLogger
- Data\Log\HtmlLogger
- Encoding\Base64Url
- Encoding\Json
- Encoding\Utf8
- Environment\DotEnv
- Environment\System
- FileSystem\Search
- FileSystem\Security
- FileSystem\Sync
- Lang\I18N
- Lang\L10N
- Lang\Time
- Media\Image
- Net\Config
- Net\Email
- Net\HttpClient
- Net\HttpResponse
- Net\IP
- Net\SmtpClient
- Security\Crypto
- Security\Password
- Security\Crypto\Encryption
- Security\Crypto\FileEncryption
- Security\Crypto\JWT
- Security\Crypto\PublicKey
- Security\Crypto\Random
- Security\Crypto\SignedData
- Security\Web\CsrfSession
- Security\Web\CsrfStateless
- Security\Web\RateLimit
- Web\Request
- Web\Response
FastSitePHP\Security\Crypto\PublicKey
Public Key Generator
Used to generate RSA Keys which can be used for JWT Signing. Function parameters allow for generation of additional public and private key types.
Código Fuente
Enlaces relacionados
Código de Ejemplo
Security - Generate a new RSA Key Pair
// Generate a new RSA Key Pair
$key_pair = \FastSitePHP\Security\Crypto\PublicKey::generateRsaKeyPair();
list($private_key, $public_key) = $key_pair;
// Generate a new 3072-Bit RSA Key
$bits = 3072;
$key_pair = \FastSitePHP\Security\Crypto\PublicKey::generateRsaKeyPair($bits);
list($private_key2, $public_key2) = $key_pair;
Métodos
defaultConfig($bits = 2048)
Return the default config options used when generating a new Key Pair. This an array of options set for a 2048-bit RSA Key.
2048-bit is used as because it is provides a combination of acceptable speed for JWT and strong security. If a JWT needs to be signed and validated after the year 2030 then a 3072-bit key is recommended, however 3072-bit keys are much slower to create.
On Windows this will attempt to find and set the [openssl.cnf] file for the instance of PHP that is running. This option is generally required in order to generate RSA Key Pairs on Windows. The file if found by default will exist at a location such as:
C:\Program Files\PHP\v7.2\extras\ssl\openssl.cnf
Returns: array
generateRsaKeyPair($bits = 2048)
Generate a new RSA Key Pair
Returns: array - [private_key, public_key]
generateKeyPair(array $config)
Generate a new Public/Private Key Pair
Returns: array - [private_key, public_key]