jer*_*ome 10 javascript encryption
以下是我正在研究的JS加密脚本的摘录.
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;
}
Run Code Online (Sandbox Code Playgroud)
任何人都可以解释使用双倍的标志<<,以及单管| ?
在剧本的后面,双重大于符号>>,也是单&符号.
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;
}
Run Code Online (Sandbox Code Playgroud)
我熟悉单个<或>,当然还有逻辑&&和逻辑|| .
思考?
tva*_*son 14
左移8位,与j逐位或.
<<是左移算子.将变量中的位移位左侧指示的位置数.
>>是右移操作员.将变量中的位向右移动指示的位置数.
|是按位OR运算符.对两个操作数中的每个位执行逻辑OR.
&是按位AND运算符.对两个操作数中的每个位执行逻辑AND.
Zen*_*non 12
| =按位或
1010
0100
----
1110
Run Code Online (Sandbox Code Playgroud)
&=按位和
1011
0110
----
0010
Run Code Online (Sandbox Code Playgroud)
所以它与&&和||相同 只用一位
<<是左移,所以
0110 << 2将数字左移两个位置,产生011000另一种方式,认为这是乘以2,所以x << 1 == x*2,x << 2 == x*2*2等等,对于x <,它是x*Math.pow(2,n)
>>
Run Code Online (Sandbox Code Playgroud)
是相反的,所以0110 >> 2 ---> 0001你可以把它想象成二分,但是四舍五入,所以它等于
Math.floor(x/Math.pow(2,n))
Run Code Online (Sandbox Code Playgroud)