https://api.vvhan.com/api/avatar/boy

技术博客分享

JavaCV音视频宝典专栏介绍和目录JavaCV实战教程,JavaCV中文文档,JavaCV中文手册,JavaCV教程

《JavaCV音视频宝典》专栏介绍和目录(JavaCV实战教程,JavaCV中文文档,JavaCV中文手册,JavaCV教程)

返回总目录:

专栏介绍

《JavaCV音视频宝典》是2022年最新推出专注于音视频开发的高级开发宝典教程系列,更加偏重综合类流媒体音视频应用,技术不在局限于JavaCV,可能会包含结合Java中较为经典的springboot,netty等综合性的技术内容来实现流媒体音视频直播服务和电台服务等应用场景。

uniapp前端生成图形验证码并校验

uniapp前端生成图形验证码并校验

一、uniapp前端生成图形验证码并校验

1、在src/utils目录下新建文件mcaptcha.js

// mcaptcha.js

export class Mcaptcha {
  constructor(options) {
    this.options = options;
    this.fontSize = options.height * 3 / 6;
    this.init();
    this.refresh();
  }
  init() {
    this.ctx = uni.createCanvasContext(this.options.el);
    this.ctx.setTextBaseline("middle");
    this.ctx.setFillStyle(this.randomColor(180, 240));
  }
  refresh() {
    var code = '';
    var txtArr = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q','r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O','P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',0,1,2,3,4,5,6,7,8,9]
    for(var i=0;i<4;i++){
      code += txtArr[this.randomNum(0, txtArr.length)];
    }
    this.options.createCodeImg = code;
    let arr = (code + '').split('');
    if (arr.length === 0) {
      arr = ['e', 'r', 'r','o','r'];
    };
    let offsetLeft = this.options.width * 0.6 / (arr.length - 1);
    let marginLeft = this.options.width * 0.2;
    arr.forEach((item, index) => {
      this.ctx.setFillStyle(this.randomColor(0, 180));
      let size = this.randomNum(24, this.fontSize);
      this.ctx.setFontSize(size);
      let dis = offsetLeft * index + marginLeft - size * 0.3;
      let deg = this.randomNum(-30, 30);
      this.ctx.translate(dis, this.options.height*0.5);
      this.ctx.rotate(deg * Math.PI / 180);
      this.ctx.fillText(item, 0, 0);
      this.ctx.rotate(-deg * Math.PI / 180);
      this.ctx.translate(-dis, -this.options.height * 0.5);
    })
    for (var i = 0; i < 4; i++) {
      this.ctx.strokeStyle = this.randomColor(40, 180);
      this.ctx.beginPath();
      this.ctx.moveTo(this.randomNum(0, this.options.width), this.randomNum(0, this.options.height));
      this.ctx.lineTo(this.randomNum(0, this.options.width), this.randomNum(0, this.options.height));
      this.ctx.stroke();
    }
    for (var i = 0; i < this.options.width / 4; i++) {
      this.ctx.fillStyle = this.randomColor(0, 255);
      this.ctx.beginPath();
      this.ctx.arc(this.randomNum(0, this.options.width), this.randomNum(0, this.options.height), 1, 0, 2 * Math.PI);
      this.ctx.fill();
    }
    this.ctx.draw();
  }
  validate(code){
    var code = code.toLowerCase();
    var v_code = this.options.createCodeImg.toLowerCase();
    console.log(code)
    console.log(v_code.substring(v_code.length - 4))
    if (code == v_code.substring(v_code.length - 4)) {
      return true;
    } else {
      return false;
    }
  }
  randomNum(min, max) {
    return Math.floor(Math.random() * (max - min) + min);
  }
  randomColor(min, max) {
    let r = this.randomNum(min, max);
    let g = this.randomNum(min, max);
    let b = this.randomNum(min, max);
    return "rgb(" + r + "," + g + "," + b + ")";
  }
}

2、在使用图形验证码的页面引入并使用

阅读摘录-给年青数学人的信

阅读摘录 —— 给年青数学人的信

1.为何学数学?

数学属于幕后。

彩虹属于个人经验。

等于连续平方之和(1+4+9+…)的唯一平方数为4900(1除外)。

2.无几乎成了律师

没有人能碰巧成为数学叫,相反,要成为数学家需要全力以赴,即使有天分的人也极容易放弃。

2021-12-19-反编译微信小程序工具之抓取小程序图片素材详细教程

反编译微信小程序工具之抓取小程序图片素材详细教程

一、关于软件

说明:本工具仅限学习使用,禁止使用此方法盗取他人的开发成果。由于经常反编译小程序,都是通过命令操作完成,步骤比较繁琐,故本人只好利用空闲时间对其进行小幅度修改,水平有限,经过慢慢研究、修改、拼凑而成。