first push

This commit is contained in:
ylyg5690
2025-07-01 19:39:13 +08:00
commit 5289483a8a
66 changed files with 10473 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
<?php
namespace app\common\utils;
class OauthClients
{
/**
* 生成 OAuth2 client 凭证
*
* @param int $idBytes 用于生成 client_id 的随机字节长度(最终 hex 长度 = $idBytes * 2)
* @param int $secretBytes 用于生成 client_secret 的随机字节长度(最终 hex 长度 = $secretBytes * 2)
* @return array ['client_id' => string, 'client_secret' => string]
*/
public function generateClientCredentials(int $idBytes = 16, int $secretBytes = 32): array
{
// 生成随机字节,并转为十六进制字符串
$clientId = bin2hex(random_bytes($idBytes));
$clientSecret = bin2hex(random_bytes($secretBytes));
return [
'client_id' => $clientId,
'client_secret' => $clientSecret,
];
}
}