javascript实现md5算法(支持微信小程序),可分多次计算

概述:

本人前端需要实现md5计算的功能,最好是能做到分多次计算。
本文所写的代码在现有md5的C++代码,反复测试对比计算过程参数,成功改造成md5的javascript代码,并成功验证好分多次计算md5数据

测试平台:

已经在如下环境中测试通过,其他平台(浏览器)应该也不会有问题:
1、nodejs中node.exe运行
2、微信小程序

功能代码:

function strMd5CtxParams() {this.md5count;this.state;this.buffer;
};function md5_init() {var md5CtxParams = new strMd5CtxParams();md5CtxParams.md5count = new Array(2);md5CtxParams.state = new Array(4);md5CtxParams.buffer = new Uint8Array(64);md5CtxParams.md5count[0] = 0;md5CtxParams.md5count[1] = 0;md5CtxParams.state[0] = 0x67452301;md5CtxParams.state[1] = 0xEFCDAB89;md5CtxParams.state[2] = 0x98BADCFE;md5CtxParams.state[3] = 0x10325476;return md5CtxParams;
}function md5_update(md5CtxParams, data, datalen) {//unsigned int i = 0;//unsigned int index = 0;//unsigned int partlen = 0;var index = 0;var i = 0;var j = 0;var partlen = 0;//index = (m_Md5Count[0] >> 3) & 0x3F;index = (md5CtxParams.md5count[0] >>> 3) & 0x3F;partlen = 64 - index;//m_Md5Count[0] += (inputlen << 3);md5CtxParams.md5count[0] = bn_u32_add(md5CtxParams.md5count[0], datalen << 3);//if(m_Md5Count[0] < (inputlen << 3)) {if (bn_u32_compare(md5CtxParams.md5count[0], datalen << 3) < 0) {//m_Md5Count[1]++;md5CtxParams.md5count[1] = bn_u32_add(md5CtxParams.md5count[1], 1);}//m_Md5Count[1] += (inputlen >> 29);md5CtxParams.md5count[1] = bn_u32_add(md5CtxParams.md5count[1], datalen >>> 29);if(datalen >= partlen) {//memcpy(&m_Buffer[index],input,partlen);for (j = 0; j < partlen; j++) {md5CtxParams.buffer[index + j] = data[j];}//Transform(m_State,m_Buffer);Transform(md5CtxParams.state, md5CtxParams.buffer, 0);for(i = partlen;i+64 <= datalen;i+=64) {//Transform(m_State, (unsigned char*)&input[i]);Transform(md5CtxParams.state, data, i);}index = 0;        }  else {i = 0;//console.log("iii");}//memcpy(&m_Buffer[index],&input[i],inputlen-i);for (j = 0; j < datalen-i; j++) {md5CtxParams.buffer[index + j] = data[i + j];}
}function md5_final(md5CtxParams) {var PADDING=[0x80,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];var index = 0,padlen = 0;var result = new Uint8Array(16);var bits = new Uint8Array(8);var i = 0;//index = (m_Md5Count[0] >> 3) & 0x3F;index = (md5CtxParams.md5count[0] >> 3) & 0x3F;padlen = (index < 56) ? (56-index) : (120-index);Encode(bits, md5CtxParams.md5count, 0, 8);md5_update(md5CtxParams, PADDING, padlen);md5_update(md5CtxParams, bits, 8);//console.log("md5_final = %d %d %d %d", md5CtxParams.state[0], md5CtxParams.state[1], md5CtxParams.state[2], md5CtxParams.state[3]);Encode(result, md5CtxParams.state, 0, 16);return result;
}function md5_str_to_array(strIn) {var bytesArray = new Uint8Array(strIn.length);var i = 0;for (i = 0; i < strIn.length; i++) {bytesArray[i] = strIn.charCodeAt(i);}return bytesArray;
}function md5_hex_to_array(hexStrIn) {var i = 0;var cnt = 0;var ele = 0;var bytesArray = null;cnt = 0;for (i = 0; i < hexStrIn.length; i++) {ele = hexStrIn.charCodeAt(i);if (ele >= 48 && ele < 48 + 10) {cnt++;}if (ele >= 65 && ele < 65 + 6) {cnt++;}if (ele >= 97 && ele < 97 + 6) {cnt++;}}bytesArray = new Uint8Array(parseInt((cnt + 1) / 2));cnt = 0;for (i = 0; i < hexStrIn.length; i++) {ele = hexStrIn.charCodeAt(i);if (ele >= 48 && ele < 48 + 10) {ele -= 48;cnt++;} else if (ele >= 65 && ele < 65 + 6) {ele = ele - 65 + 10;cnt++;} else if (ele >= 97 && ele < 97 + 6) {ele = ele - 97 + 10;cnt++;} else {continue;}if ((cnt % 2) == 1) {bytesArray[parseInt((cnt - 1) / 2)] = (ele << 4) & 0xF0;} else {bytesArray[parseInt((cnt - 1) / 2)] |= ele;}}return bytesArray;
}function md5_encode_hex(result, len) {var sha256_hex_digits = "0123456789abcdef";var output = new String();var i = 0;for (i = 0; i < len; i++) {output += sha256_hex_digits.charAt((result[i] >>> 4) & 0x0f);output += sha256_hex_digits.charAt((result[i]) & 0x0f);}return output;
}function F(x,y,z) {return ((x & y) | (~x & z));
}function G(x,y,z) {return ((x & z) | (y & ~z));
}function H(x,y,z) {return (x^y^z);
}function I(x,y,z) {return (y ^ (x | ~z));
}function ROTATE_LEFT(x, n) {x = x & 0xffffffff;return ((x << n) | (x >>> (32-n)));
}function FF(a, b, c, d, x, s, ac) {//a += F(b,c,d) + x + ac;a = bn_u32_add(a, F(b,c,d));a = bn_u32_add(a, x);a = bn_u32_add(a, ac);a = ROTATE_LEFT(a,s);//a += b;a = bn_u32_add(a, b);return a;
}function GG(a,b,c,d,x,s,ac) { //a += G(b,c,d) + x + ac; a = bn_u32_add(a, G(b,c,d));a = bn_u32_add(a, x);a = bn_u32_add(a, ac);a = ROTATE_LEFT(a,s); //a += b; a = bn_u32_add(a, b);return a;
}function HH(a,b,c,d,x,s,ac) { //a += H(b,c,d) + x + ac; a = bn_u32_add(a, H(b,c,d));a = bn_u32_add(a, x);a = bn_u32_add(a, ac);a = ROTATE_LEFT(a,s); //a += b; a = bn_u32_add(a, b);return a;
}function II(a,b,c,d,x,s,ac) { //a += H(b,c,d) + x + ac; a = bn_u32_add(a, I(b,c,d));a = bn_u32_add(a, x);a = bn_u32_add(a, ac);a = ROTATE_LEFT(a,s); //a += b; a = bn_u32_add(a, b);return a;
}function Transform(state, block, blockindex) {var x = new Array(64);//Uint8Array(64);var a = state[0];var b = state[1];var c = state[2];var d = state[3];//var i = 0;Decode(x, block, blockindex, 64);//printfIntsIndex("x", x, 0, 64);a = FF(a, b, c, d, x[ 0], 7, 0xd76aa478); /* 1 */d = FF(d, a, b, c, x[ 1], 12, 0xe8c7b756); /* 2 */c = FF(c, d, a, b, x[ 2], 17, 0x242070db); /* 3 */b = FF(b, c, d, a, x[ 3], 22, 0xc1bdceee); /* 4 */a = FF(a, b, c, d, x[ 4], 7, 0xf57c0faf); /* 5 */d = FF(d, a, b, c, x[ 5], 12, 0x4787c62a); /* 6 */c = FF(c, d, a, b, x[ 6], 17, 0xa8304613); /* 7 */b = FF(b, c, d, a, x[ 7], 22, 0xfd469501); /* 8 */a = FF(a, b, c, d, x[ 8], 7, 0x698098d8); /* 9 */d = FF(d, a, b, c, x[ 9], 12, 0x8b44f7af); /* 10 */c = FF(c, d, a, b, x[10], 17, 0xffff5bb1); /* 11 */b = FF(b, c, d, a, x[11], 22, 0x895cd7be); /* 12 */a = FF(a, b, c, d, x[12], 7, 0x6b901122); /* 13 */d = FF(d, a, b, c, x[13], 12, 0xfd987193); /* 14 */c = FF(c, d, a, b, x[14], 17, 0xa679438e); /* 15 */b = FF(b, c, d, a, x[15], 22, 0x49b40821); /* 16 *///console.log("a = %d b = %d c = %d d = %d", a, b, c, d);//console.log("3a = %d b = %d c = %d d = %d", a, b, c, d);/* Round 2 */a = GG(a, b, c, d, x[ 1], 5, 0xf61e2562); /* 17 *///console.log("4a = %d b = %d c = %d d = %d", a, b, c, d);d = GG(d, a, b, c, x[ 6], 9, 0xc040b340); /* 18 *///console.log("5a = %d b = %d c = %d d = %d", a, b, c, d);c = GG(c, d, a, b, x[11], 14, 0x265e5a51); /* 19 *///console.log("6a = %d b = %d c = %d d = %d", a, b, c, d);b = GG(b, c, d, a, x[ 0], 20, 0xe9b6c7aa); /* 20 *///console.log("7a = %d b = %d c = %d d = %d", a, b, c, d);a = GG(a, b, c, d, x[ 5], 5, 0xd62f105d); /* 21 *///console.log("8a = %d b = %d c = %d d = %d", a, b, c, d);d = GG(d, a, b, c, x[10], 9,  0x2441453); /* 22 *///console.log("9a = %d b = %d c = %d d = %d", a, b, c, d);c = GG(c, d, a, b, x[15], 14, 0xd8a1e681); /* 23 *///console.log("10a = %d b = %d c = %d d = %d", a, b, c, d);b = GG(b, c, d, a, x[ 4], 20, 0xe7d3fbc8); /* 24 *///console.log("11a = %d b = %d c = %d d = %d", a, b, c, d);a = GG(a, b, c, d, x[ 9], 5, 0x21e1cde6); /* 25 *///console.log("12a = %d b = %d c = %d d = %d", a, b, c, d);d = GG(d, a, b, c, x[14], 9, 0xc33707d6); /* 26 *///console.log("13a = %d b = %d c = %d d = %d", a, b, c, d);c = GG(c, d, a, b, x[ 3], 14, 0xf4d50d87); /* 27 *///console.log("14a = %d b = %d c = %d d = %d", a, b, c, d);b = GG(b, c, d, a, x[ 8], 20, 0x455a14ed); /* 28 *///console.log("15a = %d b = %d c = %d d = %d", a, b, c, d);a = GG(a, b, c, d, x[13], 5, 0xa9e3e905); /* 29 *///console.log("16a = %d b = %d c = %d d = %d", a, b, c, d);d = GG(d, a, b, c, x[ 2], 9, 0xfcefa3f8); /* 30 *///console.log("17a = %d b = %d c = %d d = %d", a, b, c, d);c = GG(c, d, a, b, x[ 7], 14, 0x676f02d9); /* 31 *///console.log("18a = %d b = %d c = %d d = %d", a, b, c, d);b = GG(b, c, d, a, x[12], 20, 0x8d2a4c8a); /* 32 *///console.log("2a = %d b = %d c = %d d = %d", a, b, c, d);/* Round 3 */a = HH(a, b, c, d, x[ 5], 4, 0xfffa3942); /* 33 */d = HH(d, a, b, c, x[ 8], 11, 0x8771f681); /* 34 */c = HH(c, d, a, b, x[11], 16, 0x6d9d6122); /* 35 */b = HH(b, c, d, a, x[14], 23, 0xfde5380c); /* 36 */a = HH(a, b, c, d, x[ 1], 4, 0xa4beea44); /* 37 */d = HH(d, a, b, c, x[ 4], 11, 0x4bdecfa9); /* 38 */c = HH(c, d, a, b, x[ 7], 16, 0xf6bb4b60); /* 39 */b = HH(b, c, d, a, x[10], 23, 0xbebfbc70); /* 40 */a = HH(a, b, c, d, x[13], 4, 0x289b7ec6); /* 41 */d = HH(d, a, b, c, x[ 0], 11, 0xeaa127fa); /* 42 */c = HH(c, d, a, b, x[ 3], 16, 0xd4ef3085); /* 43 */b = HH(b, c, d, a, x[ 6], 23,  0x4881d05); /* 44 */a = HH(a, b, c, d, x[ 9], 4, 0xd9d4d039); /* 45 */d = HH(d, a, b, c, x[12], 11, 0xe6db99e5); /* 46 */c = HH(c, d, a, b, x[15], 16, 0x1fa27cf8); /* 47 */b = HH(b, c, d, a, x[ 2], 23, 0xc4ac5665); /* 48 *///console.log("1a = %d b = %d c = %d d = %d", a, b, c, d);/* Round 4 */a = II(a, b, c, d, x[ 0], 6, 0xf4292244); /* 49 */d = II(d, a, b, c, x[ 7], 10, 0x432aff97); /* 50 */c = II(c, d, a, b, x[14], 15, 0xab9423a7); /* 51 */b = II(b, c, d, a, x[ 5], 21, 0xfc93a039); /* 52 */a = II(a, b, c, d, x[12], 6, 0x655b59c3); /* 53 */d = II(d, a, b, c, x[ 3], 10, 0x8f0ccc92); /* 54 */c = II(c, d, a, b, x[10], 15, 0xffeff47d); /* 55 */b = II(b, c, d, a, x[ 1], 21, 0x85845dd1); /* 56 */a = II(a, b, c, d, x[ 8], 6, 0x6fa87e4f); /* 57 */d = II(d, a, b, c, x[15], 10, 0xfe2ce6e0); /* 58 */c = II(c, d, a, b, x[ 6], 15, 0xa3014314); /* 59 */b = II(b, c, d, a, x[13], 21, 0x4e0811a1); /* 60 */a = II(a, b, c, d, x[ 4], 6, 0xf7537e82); /* 61 */d = II(d, a, b, c, x[11], 10, 0xbd3af235); /* 62 */c = II(c, d, a, b, x[ 2], 15, 0x2ad7d2bb); /* 63 */b = II(b, c, d, a, x[ 9], 21, 0xeb86d391); /* 64 *///console.log("0a = %d b = %d c = %d d = %d", a, b, c, d);//console.log("pre state = %d %d %d %d", state[0], state[1], state[2], state[3]);//state[0] += a;state[0] = bn_u32_add(state[0], a);//state[1] += b;state[1] = bn_u32_add(state[1], b);//state[2] += c;state[2] = bn_u32_add(state[2], c);//state[3] += d;state[3] = bn_u32_add(state[3], d);//throw Error("11");//console.log("state = %d %d %d %d", state[0], state[1], state[2], state[3]);//throw Error("11");
}function Decode(output, input, inputindex, len)
{var i = 0;var j = 0;while(j < len) {output[i] = ((input[j +inputindex]) & 0xff) |((input[j+1 + inputindex] & 0xff) << 8) |((input[j+2 + inputindex] & 0xff) << 16) |((input[j+3 + inputindex] & 0xff) << 24);i++;j+=4; }
}function Encode(output, input, inputindex, len)
{//unsigned int i = 0;//unsigned int j = 0;var i = 0;var j = 0;while(j < len) {output[j] = input[i + inputindex] & 0xFF;  output[j+1] = (input[i + inputindex] >>> 8) & 0xFF;output[j+2] = (input[i + inputindex] >>> 16) & 0xFF;output[j+3] = (input[i + inputindex] >>> 24) & 0xFF;i++;j+=4;}
}/*
function printfInts(title, data, len) {printfIntsIndex(title, data, 0, len);
}function printfIntsIndex(title, data, index, len) {var i = 0;for (i = 0; i < len; i++) {console.log("%d %s %d", i, title == null ? "":title, data[i + index]);}
}*/function bn_u32_compare(uint1, uint2) {uint1 &= 0xffffffff;uint2 &= 0xffffffff;if ((uint1 & 0x80000000) == 0 && (uint2 & 0x80000000) == 0) {return uint1 > uint2 ? 1 : (uint1 == uint2 ? 0 : (-1));}if ((uint1 & 0x80000000) != 0 && (uint2 & 0x80000000) != 0) {uint1 &= 0x7fffffff;uint2 &= 0x7fffffff;return uint1 > uint2 ? 1 : (uint1 == uint2 ? 0 : (-1));}if ((uint1 & 0x80000000) != 0) {return 1;} else {return -1;}
}function bn_u32_add(add1, add2) {var i = 0;var tmp = 0;var result = 0;//add1 &= 0xffffffff;//add2 &= 0xffffffff;for (i = 0; i < 4; i++) {tmp = ((add1 >>> (i * 8)) & 0xff) + ((add2 >>> (i * 8)) & 0xff) + tmp;result |= ((tmp & 0xff) << (i * 8));tmp = tmp >>> 8;}return result & 0xffffffff;
}
/*
function bn_u32_minus(minuend, subtractor) {var a = (minuend & 0xffffffff) >>> 0;var b = (subtractor & 0xffffffff) >>> 0;return (a - b) & 0xffffffff;
}
*/module.exports = {md5_init: md5_init,md5_update: md5_update,md5_final: md5_final,md5_encode_hex: md5_encode_hex,md5_str_to_array: md5_str_to_array,md5_hex_to_array: md5_hex_to_array,
}/*
var data1 = "Decrypt";
var data0 = "1234567890abcdef9999oplk8563plmh6003EBFF27AEDE040312E8D8159A91AE0149CDC9EE6775DE602739DB660D241935E8AA847EA015309664C1EBA947E0F043B8CD71240DE448F1D0B758A21E80009BA39A2799515469338E75B810C7550D2B0144DFDCEE981E3250B70F094A2AC98183DFF1B889B8249006ADAEA39504F5F4E8D3581E606D97029880DF721764FF94CD8E66BC1C924DE4451921BB95AF20DA4A9510FDDCCAF0AF88C520D5F6C942446D39079B072429FCA222250F88B753BEA4061E02364528BFEC8F66F4F67CA82CA33DEA0EDFE8FD6E4BF9226B87DB28C0DA0A776CFBD2E4977C0F1E738A443D9D4BE434B9A9F1D9B24D2ACBD7510928A8D4767E8EA8DEC66FF6587237956309";
var data2 = "96325";
//char buf[128];//EZERO_ARRAY(buf);
var md5ctx = null;
var result = null;// 字符串 
md5ctx = md5_init();
md5_update(md5ctx, md5_str_to_array(data0), data0.length);
md5_update(md5ctx, md5_str_to_array(data1), data1.length);
md5_update(md5ctx, md5_str_to_array(data2), data2.length);
result = md5_final(md5ctx);
console.log("result:" + md5_encode_hex(result, 16));// hex 
md5ctx = md5_init();
md5_update(md5ctx, md5_hex_to_array("001122334455"), 6);
md5_update(md5ctx, md5_hex_to_array("AABBCCDDEEFF"), 6);
md5_update(md5ctx, md5_hex_to_array("88"), 1);
result = md5_final(md5ctx);
console.log("result:" + md5_encode_hex(result, 16));
*/

测试代码:

如下在微信小程序中测试验证

var js_md5 = require('../../crypto/md5.js');
testMd5() {var data1 = "Decrypt";var data0 = "1234567890abcdef9999oplk8563plmh6003EBFF27AEDE040312E8D8159A91AE0149CDC9EE6775DE602739DB660D241935E8AA847EA015309664C1EBA947E0F043B8CD71240DE448F1D0B758A21E80009BA39A2799515469338E75B810C7550D2B0144DFDCEE981E3250B70F094A2AC98183DFF1B889B8249006ADAEA39504F5F4E8D3581E606D97029880DF721764FF94CD8E66BC1C924DE4451921BB95AF20DA4A9510FDDCCAF0AF88C520D5F6C942446D39079B072429FCA222250F88B753BEA4061E02364528BFEC8F66F4F67CA82CA33DEA0EDFE8FD6E4BF9226B87DB28C0DA0A776CFBD2E4977C0F1E738A443D9D4BE434B9A9F1D9B24D2ACBD7510928A8D4767E8EA8DEC66FF6587237956309";var data2 = "96325";//char buf[128];//EZERO_ARRAY(buf);var md5ctx = null;var result = null;// 字符串 md5ctx = js_md5.md5_init();js_md5.md5_update(md5ctx, js_md5.md5_str_to_array(data0), data0.length);js_md5.md5_update(md5ctx, js_md5.md5_str_to_array(data1), data1.length);js_md5.md5_update(md5ctx, js_md5.md5_str_to_array(data2), data2.length);result = js_md5.md5_final(md5ctx);console.log("result:" + js_md5.md5_encode_hex(result, 16));// hex md5ctx = js_md5.md5_init();js_md5.md5_update(md5ctx, js_md5.md5_hex_to_array("001122334455"), 6);js_md5.md5_update(md5ctx, js_md5.md5_hex_to_array("AABBCCDDEEFF"), 6);js_md5.md5_update(md5ctx, js_md5.md5_hex_to_array("88"), 1);result = js_md5.md5_final(md5ctx);console.log("result:" + js_md5.md5_encode_hex(result, 16));},

测试结果:

result:8aeec07868ee5cd179812324d28d49d6
result:89be57c106c2fa152be29148da87ea31

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/462151.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

(56)MATLAB分析码间串扰信道的传递函数与频率响应

文章目录 前言一、3个存在码间串扰的信道二、信道特性仿真三、仿真结果四、迫零均衡器与MMSE均衡器仿真总结 前言 线性均衡器的性能完全取决于通信信道的特性。本文设计了三个不同传输特性的信道&#xff0c;给出了其传递函数系数&#xff0c;然后计算并绘制了各自的频率响应。…

etcd多实例配置

多实例进行配置&#xff0c;分别在多个不同端口进行监听&#xff0c;避免开启单机部署监听端口冲突&#xff1b; 查看go版本&#xff1a; go version 若没有go环境&#xff0c;则进行下载&#xff0c;解压至/usr/local后进行环境配置&#xff0c;编辑vim ~./bashrc vim ~./b…

029_Common_Plots_Matlab常见二维绘图

常用的二维绘图 常用绘图包括下面的种类&#xff1a; 线图&#xff0c; plot柱图&#xff0c; bar梯步图&#xff0c;stairstep误差棒图&#xff0c;errorbar极坐标图&#xff0c;polarplot跟图&#xff0c;stem散点图&#xff0c;scatter 这些命令都可以通过help xxx来查看…

NuGet Next发布,全新版私有化NuGet管理

NuGet Next发布&#xff0c;全新版私有化NuGet管理 NuGet Next是一款基于BaGet的一款私有化NuGet管理平台&#xff0c;我们对BaGet进行了扩展&#xff0c;并且提供了更多的功能。 NuGet 最新版开源私有化包管理&#xff0c;我们基于BaGet的基础之上增加了更多的功能&#xff…

STM32 从0开始系统学习5

目录 STM32 GPIO输入的四种模式 Practice And Usage 练习与封装 Detailed And Reference 更加具体的说明 输入浮空模式 输入上拉模式 输入下拉模式 模拟功能 我们下面聊一聊输入的事情&#xff0c;输入指的是我们的处理器从外部端口接受外设发过来的信号。在我们没有接…

PHP反序列化原生类字符串逃逸框架反序列化利用

PHP反序列化 概念 序列化的原因&#xff1a;为了解决开发中数据传输和数据解析的一个情况(类似于要发送一个椅子快递&#xff0c;不可能整个椅子打包发送&#xff0c;这是非常不方便的&#xff0c;所以就要对椅子进行序列化处理&#xff0c;让椅子分成很多部分在一起打包发送…

WonderWorld: Interactive 3D Scene Generation from a Single Image 论文解读

目录 一、概述 二、相关工作 1、新视图生成 2、单视图3D场景生成 3、视频生成 4、快速的3D场景表示 三、WonderWorld 1、FLAGS表示 2、引导深度扩散模块 3、单视角层次生成 4、基于几何的初始化 surfel表示 5、阶段一——生成3D场景部分 6、阶段二——用户交互控…

网络:IP分片和组装

个人主页 &#xff1a; 个人主页 个人专栏 &#xff1a; 《数据结构》 《C语言》《C》《Linux》《网络》 《redis学习笔记》 文章目录 前言16位标识&#xff0c;3位标志&#xff0c;13位片偏移分片组装总结 前言 对于IP分片和组装的总结 当一个IP数据报的大小超过网络的MTU(最…

从0到1搭建flink程序-WordCount(图文/详细/mac)

目录 一、目标以及前置资料 1.1 目标 1.2 前置资料 二、实现 2.1 搭建流程 2.2 调试 参考 一、目标以及前置资料 1.1 目标 初步感受flink任务&#xff0c;从0到1快速搭建一个flink程序 1.2 前置资料 1、下载jdk&#xff1a;Mac 安装jdk_mac 安装jdk 1.8-CSDN博客 2、…

ctfshow——web(总结持续更新)

文章目录 1、基础知识部分2、php伪协议2.1 php://input协议2.2 data://text/plain协议 3、webshell连接工具3.1 蚁剑连接一句话木马 4、各个web中间件重要文件路径4.1 Nginx 5、sqlmap使用6、php特性6.1 md5加密漏洞 7、TOP 10漏洞7.1 SQL注入 1、基础知识部分 识别base64编码…

FineReport 倒计时特效

1、代码准备 将下面的代码生成对应文件 1.1、zzsc.js 这段代码是一个JavaScript计时器脚本&#xff0c;用于计算从当前时间到第二天午夜&#xff08;即0点&#xff09;之间的时间差&#xff0c;并将这个时间差显示在网页上的特定元素中。具体来说&#xff0c;它会实时更新页…

【Linux】编辑器vim 与 编译器gcc/g++

目录 一、编辑器vim&#xff1a; 1、对vim初步理解&#xff1a; 2、vim的模式&#xff1a; 3、进入与退出&#xff1a; 4、vim命令模式下的指令集&#xff1a; 移动光标&#xff1a; 删除&#xff1a; cv&#xff1a; 撤销&#xff1a; 其他&#xff1a; 5、vim底行模…

虚拟机 Ubuntu 扩容

文章目录 一、Vmware 重新分配 Ubuntu 空间二、Ubuntu 扩容分区 一、Vmware 重新分配 Ubuntu 空间 先打开 Vmware &#xff0c;选择要重新分配空间的虚拟机 点击 编辑虚拟机设置 &#xff0c;再点击 硬盘 &#xff0c;再点击 扩展 选择预计扩展的空间&#xff0c;然后点击 扩展…

【搜索引擎】俄罗斯搜索引擎yandex

俄罗斯搜索引擎yandex 1997年&#xff0c;俄罗斯搜索引擎Yandex&#xff08;俄语意为&#xff1a;语言目录&#xff09;首次上线&#xff0c;已发展成为全球第四大搜索引擎和第二大非英语搜索引擎 https://yandex.com/

【深度学习】CrossEntropyLoss需要手动softmax吗?

【深度学习】CrossEntropyLoss需要手动softmax吗&#xff1f; 问题&#xff1a;CrossEntropyLoss需要手动softmax吗&#xff1f;答案&#xff1a;不需要官方文档代码解释 问题&#xff1a;CrossEntropyLoss需要手动softmax吗&#xff1f; 之前用 pytorch 实现自己的网络时&…

Uniapp的H5以及App不支持后端传FormData类型参数的解决方案

在uniapp中不支持FormData的传参&#xff0c;这就很恶心&#xff1b;如果强行传的话会提示&#xff0c;请求失败的报错信息。 因为后端必须要FormData类型的传参&#xff0c;所以在查阅一系列方案后&#xff0c;有一种解决办法可以完美解决。 代码&#xff1a; init() {const…

img 标签的 object-fit 属性

设置图片固定尺寸后&#xff0c;可以通过 object-fit 属性调整图片展示的形式 object-fit: contain; 图片的长宽比不变&#xff0c;相应调整大小。 object-fit: cover; 当图片的长宽比与容器的长宽比不一致时&#xff0c;会被裁切。 object-fit: fill; 图片不再锁定长宽…

机器人领域中的scaling law:通过复现斯坦福机器人UMI——探讨数据规模化定律(含UMI的复现关键)

前言 在24年10.26/10.27两天&#xff0c;我司七月在线举办的七月大模型机器人线下营时&#xff0c;我们带着大家一步步复现UMI「关于什么是UMI&#xff0c;详见此文&#xff1a;UMI——斯坦福刷盘机器人&#xff1a;从手持夹持器到动作预测Diffusion Policy(含代码解读)」&…

scala---10.30

val、var package com_1030class Person {var name:String"rose"def sum(n1:Int,n2:Int):Int{n1n2} } object Person{def main(args: Array[String]): Unit {//创建person对象var personnew Person()println(person.sum(10,20))//30println(person.name)person.nam…

Oracle与SQL Server的语法区别

1&#xff09;日期和日期转换函数。 SQL: SELECT A.*, CASE WHEN NVL(PAA009,) OR PAA009 >Convert(Varchar(10), SYSDATE,120) THEN Y ELSE N END AS ActiveUser FROM POWPAA A WHERE PAA001admin or PAA002admin Oracle: SELECT A.*, CASE WHEN NVL(PAA009,) or PAA009&…