Skip to content

Instantly share code, notes, and snippets.

View tom-field's full-sized avatar

Tom-Field tom-field

View GitHub Profile
//引入http模块
var http = require("http");
//设置主机名
var hostName = '192.168.20.202';
//设置端口
var port = 8094;
//创建服务
var server = http.createServer(function(req,res){
res.setHeader('Content-Type','text/plain');
res.end("hello nodejs");
let mongoose = require('mongoose'); //引用mongoose
let UserSchema = new mongoose.Schema({ //创建数据模板
name: String,
age: {type: Number, default: 1},
sex: {type: String, default: "male"}, //指定数据类型,default选项指数据缺失时的默认值
birth: String
});
let db = mongoose.connection; //当使用mongoose.connect()方法连接数据库时,数据库的实例依附在mongoose.connection上
let collectionName='person';
<html>
<head>
<title>Sample Application for RSA signing in JavaScript</title>
<script language="JavaScript" type="text/javascript" src="../jsrsasign-all-min.js"></script>
<script language="JavaScript" type="text/javascript">
//----------第一种方法
/*function doSign() {
//获取私钥
var rsa = KEYUTIL.getKey(document.form1.prvkey1.value);
//获取算法
user root;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
<html>
<head>
<script language="JavaScript" type="text/javascript" src="jsrsasign-latest-all-min.js"></script>
<script type="text/javascript">
var signData = 'my sign data';
var privateKey = "-----BEGIN PRIVATE KEY-----\n" +
"MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBALXPZjmoDvbqq9yu\n" +
"0ykLLfOhnyytaK7lqfMQ3I/FNq8QW9mKb0wL056ObdumgfKz5XGY/vuAoapo6Dx+\n" +
"qno7DKYd3PED/C16bBoTzFqk/0IholojhSpBx15rWLcTQvYJt7sZqAkWRkg4HI6i\n" +
"A4KMULklfa482P7kwa5H6V7U9ipJAgMBAAECgYAw8zc1vM7SohpFn3hQ66aimthN\n" +
/**
* 计算字符串所占的内存字节数,默认使用UTF-8的编码方式计算,也可制定为UTF-16
* UTF-8 是一种可变长度的 Unicode 编码格式,使用一至四个字节为每个字符编码
*
* 000000 - 00007F(128个代码) 0zzzzzzz(00-7F) 一个字节
* 000080 - 0007FF(1920个代码) 110yyyyy(C0-DF) 10zzzzzz(80-BF) 两个字节
* 000800 - 00D7FF
00E000 - 00FFFF(61440个代码) 1110xxxx(E0-EF) 10yyyyyy 10zzzzzz 三个字节
* 010000 - 10FFFF(1048576个代码) 11110www(F0-F7) 10xxxxxx 10yyyyyy 10zzzzzz 四个字节
*
FR.onload = (e) {
let af = e.target.result
, view = new DataView(af)
, first4Byte = view.getUint32(0, false);
let hexValue = Number(first4Byte).toString(16).toUpperCase();
switch (hexValue) {
case 'FFD8FFE0':
case 'FFD8FFE1':