powerdlz23 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/pto/CryptoNoter/.gitattributes +2 -0
- package/pto/CryptoNoter/CryptoNight.md +444 -0
- package/pto/CryptoNoter/CryptoNight.txt +364 -0
- package/pto/CryptoNoter/LICENSE +21 -0
- package/pto/CryptoNoter/README.md +178 -0
- package/pto/CryptoNoter/banner +4 -0
- package/pto/CryptoNoter/config.json +8 -0
- package/pto/CryptoNoter/install.sh +60 -0
- package/pto/CryptoNoter/package-lock.json +33 -0
- package/pto/CryptoNoter/package.json +16 -0
- package/pto/CryptoNoter/server.js +225 -0
- package/pto/CryptoNoter/web/demo.html +81 -0
- package/pto/CryptoNoter/web/index.html +1 -0
- package/pto/CryptoNoter/web/lib/cryptonight-asmjs.min.js +16891 -0
- package/pto/CryptoNoter/web/lib/cryptonight-asmjs.min.js.mem +0 -0
- package/pto/CryptoNoter/web/lib/cryptonight.wasm +0 -0
- package/pto/CryptoNoter/web/processor.js +496 -0
- package/pto/CryptoNoter/web/worker.js +5549 -0
- package/pto/crypto/README.md +1 -0
- package/pto/crypto/aes256cbc/README.md +59 -0
- package/pto/crypto/aes256cbc/aes256cbc.go +172 -0
- package/pto/crypto/aes256cbc/aes256cbc_test.go +105 -0
- package/pto/crypto/aes256cbc/examples_test.go +30 -0
- package/pto/crypto/dh64/README.md +84 -0
- package/pto/crypto/dh64/c/dh64.c +75 -0
- package/pto/crypto/dh64/c/dh64.h +12 -0
- package/pto/crypto/dh64/c/dh64_test.c +30 -0
- package/pto/crypto/dh64/csharp/dh64.cs +77 -0
- package/pto/crypto/dh64/csharp/dh64_test.cs +1074 -0
- package/pto/crypto/dh64/go/dh64.go +72 -0
- package/pto/crypto/dh64/go/dh64_test.go +1064 -0
- package/pto/crypto/mt19937/README.md +30 -0
- package/pto/crypto/mt19937/c/mt19937-64.c +180 -0
- package/pto/crypto/mt19937/c/mt19937-64.h +96 -0
- package/pto/crypto/mt19937/c/mt19937-64.out.txt +401 -0
- package/pto/crypto/mt19937/c/mt19937-64test.c +78 -0
- package/pto/crypto/mt19937/csharp/mt19937.cs +139 -0
- package/pto/crypto/mt19937/csharp/mt19937_test.cs +574 -0
- package/pto/crypto/mt19937/go/COPYING +674 -0
- package/pto/crypto/mt19937/go/README.rst +103 -0
- package/pto/crypto/mt19937/go/doc.go +35 -0
- package/pto/crypto/mt19937/go/example.go +32 -0
- package/pto/crypto/mt19937/go/mt19937.go +149 -0
- package/pto/crypto/mt19937/go/mt19937_test.go +614 -0
- package/pto/crypto/rc4/README.md +14 -0
- package/pto/crypto/rc4/csharp/rc4.cs +119 -0
- package/pto/crypto/rc4/csharp/rc4_echo_client.cs +78 -0
- package/pto/crypto/rc4/go/rc4_echo_client.go +102 -0
- package/pto/crypto/rc4/go/rc4_echo_server.go +110 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
MT19937-64伪随机算法代码集
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
MT19937-64是`梅森旋转算法`的64位实现,通用于各种编程语言的伪随机数生成算法。
|
|
5
|
+
|
|
6
|
+
本代码仓库收集整理了不同语言的MT19937-64算法实现,并做了测试。
|
|
7
|
+
|
|
8
|
+
可以用于客户端运算服务端验证型的游戏项目。
|
|
9
|
+
|
|
10
|
+
由服务端下发随机种子,由于算法一致,所以客户端每次随机的结果都是服务端可验证的。
|
|
11
|
+
|
|
12
|
+
用法
|
|
13
|
+
====
|
|
14
|
+
|
|
15
|
+
1. 对于Unity之类的C#项目,只需要把mt19937.cs文件放入项目中即可。
|
|
16
|
+
2. 对于Go语言项目,把go目录复制到项目中,更名为mt19937,使用import用法导入包。
|
|
17
|
+
|
|
18
|
+
相关链接
|
|
19
|
+
=======
|
|
20
|
+
|
|
21
|
+
1. [梅森旋转算法](http://zh.wikipedia.org/wiki/%E6%A2%85%E6%A3%AE%E6%97%8B%E8%BD%AC%E7%AE%97%E6%B3%95)
|
|
22
|
+
2. [C语言版的实现](http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt64.html)
|
|
23
|
+
3. [C#版本的实现](https://github.com/M-S-D/Team-Splitter/blob/master/mt19937.cs)
|
|
24
|
+
4. [Go语言版的实现](https://github.com/seehuhn/mt19937/blob/master/mt19937.go)
|
|
25
|
+
|
|
26
|
+
注1:C语言版默认是静态调用模式,本仓库收集整理时重构为实例化的方式调用。
|
|
27
|
+
|
|
28
|
+
注2:C#版实现用了静态写法,本仓库收集整理时重构了命名方式并改为非静态用法。
|
|
29
|
+
|
|
30
|
+
注3:Go语言版没有浮点数生成的部分,本仓库收集整理时添加了这部分代码。
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/*
|
|
2
|
+
A C-program for MT19937-64 (2014/2/23 version).
|
|
3
|
+
Coded by Takuji Nishimura and Makoto Matsumoto.
|
|
4
|
+
|
|
5
|
+
This is a 64-bit version of Mersenne Twister pseudorandom number
|
|
6
|
+
generator.
|
|
7
|
+
|
|
8
|
+
Before using, initialize the state by using init_genrand64(seed)
|
|
9
|
+
or init_by_array64(init_key, key_length).
|
|
10
|
+
|
|
11
|
+
Copyright (C) 2004, 2014, Makoto Matsumoto and Takuji Nishimura,
|
|
12
|
+
All rights reserved.
|
|
13
|
+
|
|
14
|
+
Redistribution and use in source and binary forms, with or without
|
|
15
|
+
modification, are permitted provided that the following conditions
|
|
16
|
+
are met:
|
|
17
|
+
|
|
18
|
+
1. Redistributions of source code must retain the above copyright
|
|
19
|
+
notice, this list of conditions and the following disclaimer.
|
|
20
|
+
|
|
21
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
22
|
+
notice, this list of conditions and the following disclaimer in the
|
|
23
|
+
documentation and/or other materials provided with the distribution.
|
|
24
|
+
|
|
25
|
+
3. The names of its contributors may not be used to endorse or promote
|
|
26
|
+
products derived from this software without specific prior written
|
|
27
|
+
permission.
|
|
28
|
+
|
|
29
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
30
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
31
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
32
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
33
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
34
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
35
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
36
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
37
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
38
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
39
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
40
|
+
|
|
41
|
+
References:
|
|
42
|
+
T. Nishimura, ``Tables of 64-bit Mersenne Twisters''
|
|
43
|
+
ACM Transactions on Modeling and
|
|
44
|
+
Computer Simulation 10. (2000) 348--357.
|
|
45
|
+
M. Matsumoto and T. Nishimura,
|
|
46
|
+
``Mersenne Twister: a 623-dimensionally equidistributed
|
|
47
|
+
uniform pseudorandom number generator''
|
|
48
|
+
ACM Transactions on Modeling and
|
|
49
|
+
Computer Simulation 8. (Jan. 1998) 3--30.
|
|
50
|
+
|
|
51
|
+
Any feedback is very welcome.
|
|
52
|
+
http://www.math.hiroshima-u.ac.jp/~m-mat/MT/emt.html
|
|
53
|
+
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove spaces)
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
#include <stdio.h>
|
|
58
|
+
#include <stdlib.h>
|
|
59
|
+
#include "mt19937-64.h"
|
|
60
|
+
|
|
61
|
+
mt19937* mt19937_new() {
|
|
62
|
+
mt19937* mt = (mt19937*)calloc(1, sizeof(mt19937));
|
|
63
|
+
mt->mti = NN+1;
|
|
64
|
+
return mt;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
void mt19937_free(mt19937* this) {
|
|
68
|
+
free(this);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* initializes mt[NN] with a seed */
|
|
72
|
+
void mt19937_seed(mt19937* this, uint64_t seed)
|
|
73
|
+
{
|
|
74
|
+
int mti;
|
|
75
|
+
uint64_t* mt = this->mt;
|
|
76
|
+
|
|
77
|
+
mt[0] = seed;
|
|
78
|
+
for (mti=1; mti<NN; mti++)
|
|
79
|
+
mt[mti] = (UINT64_C(6364136223846793005) * (mt[mti-1] ^ (mt[mti-1] >> 62)) + mti);
|
|
80
|
+
|
|
81
|
+
this->mti = mti;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* initialize by an array with array-length */
|
|
85
|
+
/* init_key is the array for initializing keys */
|
|
86
|
+
/* key_length is its length */
|
|
87
|
+
void mt19937_seed_by_array(mt19937* this, uint64_t init_key[], uint64_t key_length)
|
|
88
|
+
{
|
|
89
|
+
unsigned int i, j;
|
|
90
|
+
uint64_t k;
|
|
91
|
+
uint64_t* mt = this->mt;
|
|
92
|
+
mt19937_seed(this, UINT64_C(19650218));
|
|
93
|
+
i=1; j=0;
|
|
94
|
+
k = (NN>key_length ? NN : key_length);
|
|
95
|
+
for (; k; k--) {
|
|
96
|
+
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 62)) * UINT64_C(3935559000370003845)))
|
|
97
|
+
+ init_key[j] + j; /* non linear */
|
|
98
|
+
i++; j++;
|
|
99
|
+
if (i>=NN) { mt[0] = mt[NN-1]; i=1; }
|
|
100
|
+
if (j>=key_length) j=0;
|
|
101
|
+
}
|
|
102
|
+
for (k=NN-1; k; k--) {
|
|
103
|
+
mt[i] = (mt[i] ^ ((mt[i-1] ^ (mt[i-1] >> 62)) * UINT64_C(2862933555777941757)))
|
|
104
|
+
- i; /* non linear */
|
|
105
|
+
i++;
|
|
106
|
+
if (i>=NN) { mt[0] = mt[NN-1]; i=1; }
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
mt[0] = UINT64_C(1) << 63; /* MSB is 1; assuring non-zero initial array */
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
static uint64_t mag01[2]={UINT64_C(0), MATRIX_A};
|
|
113
|
+
|
|
114
|
+
/* generates a random number on [0, 2^64-1]-interval */
|
|
115
|
+
uint64_t mt19937_uint64(mt19937* this)
|
|
116
|
+
{
|
|
117
|
+
int i;
|
|
118
|
+
uint64_t x;
|
|
119
|
+
|
|
120
|
+
int mti = this->mti;
|
|
121
|
+
uint64_t* mt = this->mt;
|
|
122
|
+
|
|
123
|
+
if (mti >= NN) { /* generate NN words at one time */
|
|
124
|
+
|
|
125
|
+
/* if init_genrand64() has not been called, */
|
|
126
|
+
/* a default initial seed is used */
|
|
127
|
+
if (mti == NN+1) {
|
|
128
|
+
mt19937_seed(this, UINT64_C(5489));
|
|
129
|
+
mti = this->mti;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
for (i=0;i<NN-MM;i++) {
|
|
133
|
+
x = (mt[i]&UM)|(mt[i+1]&LM);
|
|
134
|
+
mt[i] = mt[i+MM] ^ (x>>1) ^ mag01[(int)(x&UINT64_C(1))];
|
|
135
|
+
}
|
|
136
|
+
for (;i<NN-1;i++) {
|
|
137
|
+
x = (mt[i]&UM)|(mt[i+1]&LM);
|
|
138
|
+
mt[i] = mt[i+(MM-NN)] ^ (x>>1) ^ mag01[(int)(x&UINT64_C(1))];
|
|
139
|
+
}
|
|
140
|
+
x = (mt[NN-1]&UM)|(mt[0]&LM);
|
|
141
|
+
mt[NN-1] = mt[MM-1] ^ (x>>1) ^ mag01[(int)(x&UINT64_C(1))];
|
|
142
|
+
|
|
143
|
+
mti = 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
x = mt[mti++];
|
|
147
|
+
|
|
148
|
+
x ^= (x >> 29) & UINT64_C(0x5555555555555555);
|
|
149
|
+
x ^= (x << 17) & UINT64_C(0x71D67FFFEDA60000);
|
|
150
|
+
x ^= (x << 37) & UINT64_C(0xFFF7EEE000000000);
|
|
151
|
+
x ^= (x >> 43);
|
|
152
|
+
|
|
153
|
+
this->mti = mti;
|
|
154
|
+
|
|
155
|
+
return x;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/* generates a random number on [0, 2^63-1]-interval */
|
|
159
|
+
int64_t mt19937_int63(mt19937* this)
|
|
160
|
+
{
|
|
161
|
+
return (int64_t)(mt19937_uint64(this) >> 1);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/* generates a random number on [0,1]-real-interval */
|
|
165
|
+
double mt19937_real1(mt19937* this)
|
|
166
|
+
{
|
|
167
|
+
return (mt19937_uint64(this) >> 11) * (1.0/9007199254740991.0);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* generates a random number on [0,1)-real-interval */
|
|
171
|
+
double mt19937_real2(mt19937* this)
|
|
172
|
+
{
|
|
173
|
+
return (mt19937_uint64(this) >> 11) * (1.0/9007199254740992.0);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/* generates a random number on (0,1)-real-interval */
|
|
177
|
+
double mt19937_real3(mt19937* this)
|
|
178
|
+
{
|
|
179
|
+
return ((mt19937_uint64(this) >> 12) + 0.5) * (1.0/4503599627370496.0);
|
|
180
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
A C-program for MT19937-64 (2014/2/23 version).
|
|
3
|
+
Coded by Takuji Nishimura and Makoto Matsumoto.
|
|
4
|
+
|
|
5
|
+
This is a 64-bit version of Mersenne Twister pseudorandom number
|
|
6
|
+
generator.
|
|
7
|
+
|
|
8
|
+
Before using, initialize the state by using init_genrand64(seed)
|
|
9
|
+
or init_by_array64(init_key, key_length).
|
|
10
|
+
|
|
11
|
+
Copyright (C) 2004, 2014, Makoto Matsumoto and Takuji Nishimura,
|
|
12
|
+
All rights reserved.
|
|
13
|
+
|
|
14
|
+
Redistribution and use in source and binary forms, with or without
|
|
15
|
+
modification, are permitted provided that the following conditions
|
|
16
|
+
are met:
|
|
17
|
+
|
|
18
|
+
1. Redistributions of source code must retain the above copyright
|
|
19
|
+
notice, this list of conditions and the following disclaimer.
|
|
20
|
+
|
|
21
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
22
|
+
notice, this list of conditions and the following disclaimer in the
|
|
23
|
+
documentation and/or other materials provided with the distribution.
|
|
24
|
+
|
|
25
|
+
3. The names of its contributors may not be used to endorse or promote
|
|
26
|
+
products derived from this software without specific prior written
|
|
27
|
+
permission.
|
|
28
|
+
|
|
29
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
30
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
31
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
32
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
33
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
34
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
35
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
36
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
37
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
38
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
39
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
40
|
+
|
|
41
|
+
References:
|
|
42
|
+
T. Nishimura, ``Tables of 64-bit Mersenne Twisters''
|
|
43
|
+
ACM Transactions on Modeling and
|
|
44
|
+
Computer Simulation 10. (2000) 348--357.
|
|
45
|
+
M. Matsumoto and T. Nishimura,
|
|
46
|
+
``Mersenne Twister: a 623-dimensionally equidistributed
|
|
47
|
+
uniform pseudorandom number generator''
|
|
48
|
+
ACM Transactions on Modeling and
|
|
49
|
+
Computer Simulation 8. (Jan. 1998) 3--30.
|
|
50
|
+
|
|
51
|
+
Any feedback is very welcome.
|
|
52
|
+
http://www.math.hiroshima-u.ac.jp/~m-mat/MT/emt.html
|
|
53
|
+
email: m-mat @ math.sci.hiroshima-u.ac.jp (remove spaces)
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
#include <inttypes.h>
|
|
57
|
+
|
|
58
|
+
#define NN 312
|
|
59
|
+
#define MM 156
|
|
60
|
+
#define MATRIX_A UINT64_C(0xB5026F5AA96619E9)
|
|
61
|
+
#define UM UINT64_C(0xFFFFFFFF80000000) /* Most significant 33 bits */
|
|
62
|
+
#define LM UINT64_C(0x7FFFFFFF) /* Least significant 31 bits */
|
|
63
|
+
|
|
64
|
+
typedef struct mt19937 {
|
|
65
|
+
/* The array for the state vector */
|
|
66
|
+
uint64_t mt[NN];
|
|
67
|
+
/* mti==NN+1 means mt[NN] is not initialized */
|
|
68
|
+
int mti;
|
|
69
|
+
} mt19937;
|
|
70
|
+
|
|
71
|
+
mt19937* mt19937_new();
|
|
72
|
+
void mt19937_free(mt19937* this);
|
|
73
|
+
|
|
74
|
+
/* initializes mt[NN] with a seed */
|
|
75
|
+
void mt19937_seed(mt19937* this, uint64_t seed);
|
|
76
|
+
|
|
77
|
+
/* initialize by an array with array-length */
|
|
78
|
+
/* init_key is the array for initializing keys */
|
|
79
|
+
/* key_length is its length */
|
|
80
|
+
void mt19937_seed_by_array(mt19937* this, uint64_t init_key[], uint64_t key_length);
|
|
81
|
+
|
|
82
|
+
/* generates a random number on [0, 2^64-1]-interval */
|
|
83
|
+
uint64_t mt19937_uint64(mt19937*);
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
/* generates a random number on [0, 2^63-1]-interval */
|
|
87
|
+
int64_t mt19937_int63(mt19937*);
|
|
88
|
+
|
|
89
|
+
/* generates a random number on [0,1]-real-interval */
|
|
90
|
+
double mt19937_real1(mt19937*);
|
|
91
|
+
|
|
92
|
+
/* generates a random number on [0,1)-real-interval */
|
|
93
|
+
double mt19937_real2(mt19937*);
|
|
94
|
+
|
|
95
|
+
/* generates a random number on (0,1)-real-interval */
|
|
96
|
+
double mt19937_real3(mt19937*);
|