Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

添加获取明文验证码方法。 #23

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Captcha.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class Captcha

private $im = null; // 验证码图片实例
private $color = null; // 验证码字体颜色
private $captcha_code = null; // 明文验证码

/**
* 架构方法 设置参数
Expand Down Expand Up @@ -192,6 +193,9 @@ public function entry($id = '')
}
}

// 保存原始明文验证码
$this->captcha_code = strtoupper(implode('', $code));

// 保存验证码
$key = $this->authcode($this->seKey);
$code = $this->authcode(strtoupper(implode('', $code)));
Expand All @@ -209,6 +213,17 @@ public function entry($id = '')
return response($content, 200, ['Content-Length' => strlen($content)])->contentType('image/png');
}

/**
* 获取明文验证码
* @author kangkst <kst157521@163.com>
* @since 1.0.0
* @date 2018-03-15 10:24:53
* @return null
*/
public function getCaptchaCode()
{
return $this->captcha_code;
}
/**
* 画一条由两条连在一起构成的随机正弦函数曲线作干扰线(你可以改成更帅的曲线函数)
*
Expand Down