Giter Site home page Giter Site logo

yiyungent / simcaptcha Goto Github PK

View Code? Open in Web Editor NEW
79.0 79.0 21.0 21.69 MB

✅ 简单易用的点触验证码 (前端+后端)

Home Page: http://yiyungent.github.io/SimCaptcha/

License: MIT License

C# 99.32% PowerShell 0.68%
captcha netcore netstandard simcaptcha

simcaptcha's Introduction

simcaptcha's People

Contributors

yiyungent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

simcaptcha's Issues

Docker下 System.Drawing.Image.FromFile 不可用

image

System.TypeInitializationException: The type initializer for 'Gdip' threw an exception.
 ---> System.DllNotFoundException: Unable to load shared library 'libgdiplus' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: liblibgdiplus: cannot open shared object file: No such file or directory
   at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInput& input, StartupOutput& output)
   at System.Drawing.SafeNativeMethods.Gdip..cctor()
   --- End of inner exception stack trace ---
   at System.Drawing.SafeNativeMethods.Gdip.GdipLoadImageFromFile(String filename, IntPtr& image)
   at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
   at System.Drawing.Image.FromFile(String filename)
   at SimCaptcha.AspNetCore.AspNetCoreVCodeImage.Create(String code, Int32 width, Int32 height) in /src/src/SimCaptcha.AspNetCore/AspNetCoreVCodeImage.cs:line 54
   at SimCaptcha.SimCaptchaService.CreateVCodeImg() in /src/src/SimCaptcha/SimCaptchaService.cs:line 484
   at SimCaptcha.SimCaptchaService.VCode() in /src/src/SimCaptcha/SimCaptchaService.cs:line 408

文件位置:
src/SimCaptcha.AspNetCore/AspNetCoreVCodeImage.cs:line 54

var imageStream = Image.FromFile(randomImgFile);

获取被点击元素在此元素内的坐标

/**
* 获取点击位置(相对于图片的相对位置)(px)
* @param obj 事实上始终为验证码图片元素
* @param event 验证码图被点击的事件
* @return {Object} { x: 123, y:123 } (px)
*/
function getImgClickPos(obj, event) {
// https://www.cnblogs.com/jiangxiaobo/p/6593584.html
// (1)原生js
// var clickX = event.clientX + document.body.scrollLeft;// 点击x 相对于整个html文档
// var clickY = event.clientY + document.body.scrollTop;// 点击y 相对于整个html文档
// var objX = getOffsetLeft(obj);// 对象x 相对于整个html文档
// var objY = getOffsetTop(obj);// 对象y 相对于整个html文档
// var xOffset = clickX - objX;
// var yOffset = clickY - objY;
// // 临时修复位置不正确
// xOffset = xOffset + 200 - 10 - 10;
// yOffset = yOffset + 200 - 10 - 10;
// (2)不考虑Firefox // TODO: 依旧位置不正确
var xOffset = event.offsetX;
var yOffset = event.offsetY;
// (3)依赖 jQuery
// var xOffset = event.clientX - ($(obj).offset().left - $(window).scrollLeft());;
// var yOffset = event.clientY - ($(obj).offset().top - $(window).scrollTop());;
// TODO: 待修复, 位置不正确
return { x: xOffset, y: yOffset };
}

当前使用event.offsetX, 不支持Firefox
参考: https://www.cnblogs.com/jiangxiaobo/p/6593584.html

AES加密再解密后, 导致多出0, 以至于无法再转为json对象

string vCodeKeyJsonStr = AesHelper.DecryptEcbMode(rightVCodeKey, _options.AesKey);
// json -> 对象
VCodeKeyModel vCodeKeyModel = null;
try
{
// TODO: fixed: 临时修复, 直接将全部为0的字节去除,
byte[] bytes = Encoding.UTF8.GetBytes(vCodeKeyJsonStr);
byte[] remove0Bytes = bytes.Where(m => m != 0).ToArray();
string remove0ByteStr = Encoding.UTF8.GetString(remove0Bytes);
// 能够转换为 对象, 则说明 vCodeKey 无误, 可以使用
//vCodeKeyModel = JsonHelper.Deserialize<VCodeKeyModel>(vCodeKeyJsonStr);
vCodeKeyModel = JsonHelper.Deserialize<VCodeKeyModel>(remove0ByteStr);
}
catch (Exception ex)
{
// TODO: BUG: 经加密再解密后的jsonStr,虽然看起来一样,但发生了一点改变, 导致无法转换
// '0x00' is invalid after a single JSON value. Expected end of data. LineNumber: 0 | BytePositionInLine: 110.
}

经加密再解密后的jsonStr,虽然看起来一样,但发生了一点改变, 导致无法转换
// '0x00' is invalid after a single JSON value. Expected end of data. LineNumber: 0 | BytePositionInLine: 110.

Docker下 | 效验失败 | System.Net.WebException: Cannot assign requested address

System.Net.WebException: Cannot assign requested address

System.Net.WebException: Cannot assign requested address Cannot assign requested address
 ---> System.Net.Http.HttpRequestException: Cannot assign requested address
 ---> System.Net.Sockets.SocketException (99): Cannot assign requested address
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at System.Net.HttpWebRequest.SendRequest()
   at System.Net.HttpWebRequest.GetResponse()
   --- End of inner exception stack trace ---
   at SimCaptcha.Common.HttpAide.HttpPost(String url, String postDataStr, StringBuilder responseHeadersSb, String[] headers, WebProxy proxy) in /src/src/SimCaptcha/Common/HttpAide.cs:line 184
   at SimCaptcha.SimCaptchaClient.Verify(String ticket, String userId, String userIp) in /src/src/SimCaptcha/SimCaptchaClient.cs:line 84

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.