js to implement verification code interference (static)

js to implement verification code interference (static)

This article shares the specific code of js to implement verification code interference for your reference. The specific content is as follows

Effect

Code

<!DOCTYPE html>
<html>
 <head>
 <meta charset="UTF-8">
 <title></title>
 <style>
  *{
  padding: 0;
  margin: 0;
  }
  canvas{
  background: #272822;
  }
 </style>
 </head>
 <body>
 <canvas id='canvas' width='800' height='500'></canvas>
 <script>
  //Get the drawing board var canvas=document.getElementById('canvas');
  //Get the drawing environment var cv=canvas.getContext('2d');
  
  cv.fillStyle = '#272822';
  cv2.fillRect(0,0,800,500);
  cv.font='80px Microsoft YaHei';
  cv2.fillStyle='greenyellow';
  cv2.fillText( Math.floor(Math.random()*10000),200,200);
  
  //Get all image pixel information var alldata=cv.getImageData(0,0,800,500);
  //Get the number of pixels var dian=alldata.data.length/4;
  for(var i=0;i<10000;i++){
  //Get a random number var num=Math.floor(Math.random()*dian);
  //Calculate the starting number of the four pieces of information corresponding to the pixel var start=(num-1)*4;
  alldata.data[start]=Math.floor(Math.random()*256);
  alldata.data[start+1]=Math.floor(Math.random()*256);
  alldata.data[start+2]=Math.floor(Math.random()*256);
  }
  //Write the data back to the drawing board cv.putImageData(alldata,0,0);
 </script>
 </body>
</html>

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • JavaScript writing verification code script example with rotation + line interference

<<:  Detailed explanation of Docker Volume permission management

>>:  Example of integrating Kafka with Nginx

Recommend

Zookeeper stand-alone environment and cluster environment construction

1. Single machine environment construction# 1.1 D...

Steps to use autoconf to generate Makefile and compile the project

Preface Under Linux, compilation and linking requ...

Handwritten Vue2.0 data hijacking example

Table of contents 1: Build webpack 2. Data hijack...

CSS sample code to achieve circular gradient progress bar effect

Implementation ideas The outermost is a big circl...

Docker network principles and detailed analysis of custom networks

Docker virtualizes a bridge on the host machine. ...

Detailed explanation of component development of Vue drop-down menu

This article example shares the specific code for...

Detailed steps for deploying Microsoft Sql Server with Docker

Table of contents 1 Background 2 Create a contain...

Introduction to Jenkins and how to deploy Jenkins with Docker

1. Related concepts 1.1 Jenkins Concepts: Jenkins...

Key features of InnoDB - insert cache, write twice, adaptive hash index details

The key features of the InnoDB storage engine inc...

Two ways to write stored procedures in Mysql with and without return values

Process 1: with return value: drop procedure if e...

Example code for implementing page floating box based on JS

When the scroll bar is pulled down, the floating ...

Detailed explanation of the frame and rules attributes of the table in HTML

The frame and rules attributes of the table tag c...

JS removeAttribute() method to delete an attribute of an element

In JavaScript, use the removeAttribute() method o...