1. 驗證碼介面
$captcha = captcha();
$data['data'] = [
'img' => "data:image/png;base64," . base64_encode($captcha->getData()),
'key' => uniqid()
];
$data['status'] = 200;
return json($data);
2.驗證
$code = '使用者輸入的驗證碼';
$key = session('captcha.key');
if(!password_verify(mb_strtolower($code, 'UTF-8'), $key)){
//驗證碼錯誤
}