diff --git "a/\350\265\226\350\231\271\351\234\226/20220304http/demo.js" "b/\350\265\226\350\231\271\351\234\226/20220304http/demo.js" new file mode 100644 index 0000000000000000000000000000000000000000..3cceb74d34e05d404995129f65834117056f742f --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220304http/demo.js" @@ -0,0 +1,24 @@ +let http = require("http"); +let fs = require("fs"); + +let server = http.createServer(); + +server.on('request', (req, res) => { + console.log(req.url); + res.setHeader("Content-Type", "text/html; charset=utf-8"); + + if (req.url == '/index.html') { + let buf = fs.readFileSync('./index.html'); + res.write(buf); + res.end("写入成功"); + }else if(req.url == '/index1.html'){ + let buf = fs.readFileSync('./index1.html'); + res.write(buf); + res.end("写入成功"); + } + res.end("欢迎" + '
' + '点击写入第一个页面内容' + '
' +'点击写入第二个页面') +}) + +server.listen(8080, () => { + console.log('server running at http://127.0.0.1:8080') +}) diff --git "a/\350\265\226\350\231\271\351\234\226/20220304http/index.html" "b/\350\265\226\350\231\271\351\234\226/20220304http/index.html" new file mode 100644 index 0000000000000000000000000000000000000000..abf7bab3a11ce5904e9991cdaeaa8f50e52a002c --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220304http/index.html" @@ -0,0 +1,13 @@ + + + + + + Document + + +
+ 百度 + + + \ No newline at end of file diff --git "a/\350\265\226\350\231\271\351\234\226/20220304http/index1.html" "b/\350\265\226\350\231\271\351\234\226/20220304http/index1.html" new file mode 100644 index 0000000000000000000000000000000000000000..a2e5c94058e90e9adc795a2d70a4d12686d90f51 --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220304http/index1.html" @@ -0,0 +1,16 @@ + + + + + + Document + + +
+ git +

第二个页面

+
+ + + + \ No newline at end of file diff --git "a/\350\265\226\350\231\271\351\234\226/20220308mysql/mysql.js" "b/\350\265\226\350\231\271\351\234\226/20220308mysql/mysql.js" new file mode 100644 index 0000000000000000000000000000000000000000..c4e449bbcb3e5147c671ec8b59da3839b0a61089 --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220308mysql/mysql.js" @@ -0,0 +1,60 @@ +let mysql = require("mysql"); +let connection = mysql.createConnection({ host: 'localhost', port: '3306', user: 'root', password: '123456', database: 'yiqing' }); +connection.connect(); +let curd={ + cha:function(date){ + let sql="select * from number where date='"+date+"'"; + connection.query(sql,function(err,rows){ + if(err){ + console.log(err.message); + return ; + } + console.log(rows); + }); + }, + add:function(nums,date,ctiy){ + let sql1="INSERT into number(nums,date,city)VALUES('"+nums+"','"+date+"','"+ctiy+"')"; + connection.query(sql1,function(err,rows){ + if(err){ + console.log(err.message); + return ; + } + console.log(rows); + console.log("添加成功"); + }); + }, + update:function(id,city){ + let sql1="UPDATE number SET city='"+city+"' WHERE id='"+id+"'"; + connection.query(sql1,function(err,rows){ + if(err){ + console.log(err.message); + return ; + } + console.log(rows); + console.log( "修改成功"); + }); + }, + delete:function(id){ + let sql1="DELETE FROM number WHERE id= '"+id+"'"; + connection.query(sql1,function(err,rows){ + if(err){ + console.log(err.message); + return ; + } + console.log(rows); + console.log("删除成功"); + }); + }, + +} +//输入时间查询信息 +curd.cha("2022-3-14"); +//输入新增人数,时间,城市 添加数据 +curd.add(0,"2022-3-15","东莞") +//输入要修改的id 修改城市名称 + curd.update(4,"龙岩"); +//输入要删除的id +curd.delete(1); +connection.end(); + + diff --git "a/\350\265\226\350\231\271\351\234\226/20220308mysql/yiqing.sql" "b/\350\265\226\350\231\271\351\234\226/20220308mysql/yiqing.sql" new file mode 100644 index 0000000000000000000000000000000000000000..0fa5e6d57bee7a589797af90d65152cd061b5ef8 --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220308mysql/yiqing.sql" @@ -0,0 +1,52 @@ +/* +Navicat MySQL Data Transfer + +Source Server : loclahost +Source Server Version : 50553 +Source Host : localhost:3306 +Source Database : yiqing + +Target Server Type : MYSQL +Target Server Version : 50553 +File Encoding : 65001 + +Date: 2022-03-15 16:10:32 +*/ + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for number +-- ---------------------------- +DROP TABLE IF EXISTS `number`; +CREATE TABLE `number` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `nums` smallint(6) DEFAULT NULL, + `date` varchar(255) DEFAULT NULL, + `city` varchar(64) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=5 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of number +-- ---------------------------- +INSERT INTO `number` VALUES ('1', '0', '2022-3-15', '龙岩'); +INSERT INTO `number` VALUES ('2', '3', '2022-3-15', '厦门'); +INSERT INTO `number` VALUES ('3', '0', '2022-3-14', '龙岩'); +INSERT INTO `number` VALUES ('4', '0', '2022-3-14', '厦门'); + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `id` int(11) NOT NULL AUTO_INCREMENT, + `name` varchar(64) DEFAULT NULL, + `password` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM AUTO_INCREMENT=2 DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES ('1', 'user', '123456'); diff --git "a/\350\265\226\350\231\271\351\234\226/20220309\345\212\240\350\247\243\345\257\206/demo01.js" "b/\350\265\226\350\231\271\351\234\226/20220309\345\212\240\350\247\243\345\257\206/demo01.js" new file mode 100644 index 0000000000000000000000000000000000000000..7b9ba8a317ffb33b117d029ae912f07ca77c291b --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220309\345\212\240\350\247\243\345\257\206/demo01.js" @@ -0,0 +1,80 @@ +/** + * 作业: + * 结合数据库与md5设计一个用户表(user),有用户名字段username与password字段还可以有别的字段,password字段采用md5(16进制 hex)加密, + * 实现增加数据(写入数据时password采用md5加密),与查询数据(查询数据时,通过明文md5加密查询); + */ +let mysql = require("mysql"); +const crypto = require('crypto'); +let connection = mysql.createConnection({ host: 'localhost', port: '3306', user: 'root', password: '123456', database: 'jjm' }); +connection.connect(); +let curd={ + cha:function(password){ + let sql="select * from user where password='"+password+"'"; + connection.query(sql,function(err,rows){ + if(err){ + console.log(err.message); + return ; + } + let ajm = jjm.aesDecrypt(password,'node'); + + password=ajm + for(let i in rows){ + console.log("username:"+rows[i].username); + console.log("password:"+password); + } + }); + }, + add:function(username,password){ + let ajm = jjm.aesEncrypt(password,'node'); + password=ajm + let sql1="INSERT into user(username,password)VALUES('"+username+"','"+password+"')"; + connection.query(sql1,function(err,rows){ + if(err){ + console.log(err.message); + return ; + } + + console.log("添加成功"); + + }); + } + +} +let jjm={ + aesEncrypt:function (data,key){ + let ciper=crypto.createCipher('aes192',key); + let returnStr=ciper.update(data,'utf8','hex'); + let final=ciper.final('hex'); + returnStr=returnStr+final; + return returnStr; +}, +aesDecrypt:function (encrypted,key){ + const deciper=crypto.createDecipher('aes192',key); + let descrped = deciper.update(encrypted,'hex','utf8'); + descrped+=deciper.final('utf8') + return descrped; +} +} + +//输入新增名称与密码 +// curd.add("2022312","123") +// curd.add("2022313","1234") +// curd.add("2022314","12345") +// curd.add("2022315","123456") +curd.cha("777da2843c80f4e6be3b289de5208c13"); +connection.end(); + + + + + + + + + + +`` + + + + diff --git "a/\350\265\226\350\231\271\351\234\226/20220309\345\212\240\350\247\243\345\257\206/jjm.sql" "b/\350\265\226\350\231\271\351\234\226/20220309\345\212\240\350\247\243\345\257\206/jjm.sql" new file mode 100644 index 0000000000000000000000000000000000000000..52317530558fc5b843942ba6860f09baeaec67da --- /dev/null +++ "b/\350\265\226\350\231\271\351\234\226/20220309\345\212\240\350\247\243\345\257\206/jjm.sql" @@ -0,0 +1,34 @@ +/* +Navicat MySQL Data Transfer + +Source Server : 127.0.0.1_3306 +Source Server Version : 50730 +Source Host : 127.0.0.1:3306 +Source Database : jjm + +Target Server Type : MYSQL +Target Server Version : 50730 +File Encoding : 65001 + +Date: 2022-03-23 11:16:15 +*/ + +SET FOREIGN_KEY_CHECKS=0; + +-- ---------------------------- +-- Table structure for user +-- ---------------------------- +DROP TABLE IF EXISTS `user`; +CREATE TABLE `user` ( + `username` varchar(255) NOT NULL, + `password` varchar(255) DEFAULT NULL +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- ---------------------------- +-- Records of user +-- ---------------------------- +INSERT INTO `user` VALUES ('2022316', '5c678b59bf16220b1face13b01824944'); +INSERT INTO `user` VALUES ('2022312', '5c678b59bf16220b1face13b01824944'); +INSERT INTO `user` VALUES ('2022313', 'b98187ee6415d119b8c3fa6badc51632'); +INSERT INTO `user` VALUES ('2022314', '2128f344b171e91714e398a268b66971'); +INSERT INTO `user` VALUES ('2022315', '777da2843c80f4e6be3b289de5208c13');