JavaScript加密脚本中使用的不熟悉的字符 [英] Unfamiliar characters used in JavaScript encryption script
问题描述
function permutationGenerator(nNumElements){
this.nNumElements = nNumElements;
this.antranspositions = new Array;
var k = 0; (i = 0; i< nNumElements - 1; i ++)
(j = i + 1; j< nNumElements; j ++)
this.antranspositions [k ++] = i<< 8)|焦耳;
//保持两个位置作为lo和hi字节!
this.nNumtranspositions = k;
this.fromCycle = permutationGenerator_fromCycle;
}
任何人都可以解释使用双重小于符号<以及单管道| ?
在脚本的后面,双倍大于符号也出现>>,也是单个&符号。
function permutationGenerator_fromCycle(anCycle){
var anpermutation = new Array(this.nNumElements); (var i = 0; i< this.nNumElements; i ++)ancolorutation [i] = i;
(var i = 0; i< anCycle.length; i ++){
var nT = this.antranspositions [anCycle [i]];
var n1 = nT& 255;
var n2 =(nT>> 8)& 255; // JC
nT = anatomutation [n1];
anatomutation [n1] = anpermutation [n2];
anatomutation [n2] = nT;
}
返回anpermutation;
}
我熟悉单一<或>当然逻辑和和逻辑||
想法?
左移8位和按位OR与j。
<
是左移操作符。将变量中的位移动留下指示的位置数。
>>
是右移操作符。将变量中的位向右移动指示的位置数。
|
是按位OR运算符。在两个操作数的每一位上执行逻辑或。
&
是按位AND运算符。对两个操作数中的每一位执行逻辑和。
Here is an excerpt from a JS encryption script that I am studying.
function permutationGenerator(nNumElements) {
this.nNumElements = nNumElements;
this.antranspositions = new Array;
var k = 0;
for (i = 0; i < nNumElements - 1; i++)
for (j = i + 1; j < nNumElements; j++)
this.antranspositions[ k++ ] = ( i << 8 ) | j;
// keep two positions as lo and hi byte!
this.nNumtranspositions = k;
this.fromCycle = permutationGenerator_fromCycle;
}
Can anyone explain the use of the double less than signs <<, as well as the single pipe | ?
Later in the script double greater than signs occur as well >>, also single ampersand & .
function permutationGenerator_fromCycle(anCycle) {
var anpermutation = new Array(this.nNumElements);
for (var i = 0; i < this.nNumElements; i++) anpermutation[i] = i;
for (var i = 0; i < anCycle.length; i++) {
var nT = this.antranspositions[anCycle[i]];
var n1 = nT & 255;
var n2 = (nT >> 8) & 255; // JC
nT = anpermutation[n1];
anpermutation[n1] = anpermutation[n2];
anpermutation[n2] = nT;
}
return anpermutation;
}
I am familiar with single < or > and of course logical && and logical || .
Thoughts?
Left shift 8 bits and bitwise OR with j.
<<
is the left shift operator. Shifts the bits in the variable left the number of positions indicated.
>>
is the right shift operator. Shifts the bits in the variable right the number of position indicated.
|
is the bitwise OR operator. Performs a logical OR on each bit in the two operands.
&
is the bitwise AND operator. Performs a logical AND on each bit in the two operands.
这篇关于JavaScript加密脚本中使用的不熟悉的字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!