提交 2a7bd22a 编写于 作者: 麦壳饼's avatar 麦壳饼

Make sure that using this pseudorandom number generator is safe here.

上级 7711bfb9
......@@ -12,6 +12,7 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
namespace IoTSharp.Controllers
{
......@@ -21,7 +22,6 @@ namespace IoTSharp.Controllers
[Route("api/[controller]/[action]")]
public class CaptchaController : ControllerBase
{
private readonly Random random = new Random();
private readonly IEasyCachingProvider _caching;
private readonly IWebHostEnvironment _hostingEnvironment;
......@@ -84,7 +84,7 @@ namespace IoTSharp.Controllers
private ModelCaptcha CreateImage()
{
using var buzzlefile = new MemoryStream(Properties.Resources.ResourceManager.GetObject("buzzle_template_png") as byte[]);
using var orginfile = new MemoryStream(Properties.Resources.ResourceManager.GetObject($"slide{random.Next(1, 9)}_jpg") as byte[]);
using var orginfile = new MemoryStream(Properties.Resources.ResourceManager.GetObject($"slide{RandomNumberGenerator.GetInt32(1,9)}_jpg") as byte[]);
using var buzzlefilestream = new SKManagedStream(buzzlefile);
using var orginfilestream = new SKManagedStream(orginfile);
using var buzzle = SKBitmap.Decode(buzzlefilestream);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册