背景

无聊试着搭了个自用机场,听说AEAD加密更不容易被检测,因此打算限制可以选择的加密方式(

开工

首先通过 DevTools 找到修改加密方式的API /user/method
然后在路由 config/routes.php 中找到 UserController
接下来直接去修改 app/Controllers/UserController.php 即可

代码

添加在updateMethod里的$user->method = $method;后即可

以下代码添加前建议适当修改

禁止用户选择非AEAD加密方式

if (!in_array($method, array('aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm', 'chacha20-ietf-poly1305', 'xchacha20-ietf-poly1305'))) {
    $res['ret'] = 0;
    $res['msg'] = '为确保安全,您仅可使用<strong>AEAD加密算法</strong>,请在以下加密方式中选择:<br><strong>aes-128-gcm</strong><br><strong>aes-192-gcm</strong><br><strong>aes-256-gcm</strong><br><strong>chacha20-ietf-poly1305</strong><br><strong>xchacha20-ietf-poly1305</strong>';
    return $this->echoJson($response, $res);
}