SHARE
TWEET

thinbus srp php fix to issue #10

a guest Apr 19th, 2017 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public function testCreateRandomBigIntegerInRange() {
  2.        
  3.         $N_base10str = "255";
  4.         $N = new BigInteger($N_base10str, 10);
  5.         $g_base10str = "1";
  6.         $k_base16str = "1";
  7.        
  8.         $Srp = new ThinbusSrp($N_base10str, $g_base10str, $k_base16str, "sha256");
  9.        
  10.         $values = array();
  11.         for( $i = 0; $i < 256; ++$i) {
  12.             $values[$i] = 0;
  13.         }
  14.         for( $i = 0; $i < 1e4; ++$i) {
  15.             $r = $Srp->createRandomBigIntegerInRange($N);
  16.             $h = $r->toHex();
  17.             $n = hexdec($h);
  18.             $c = $values[$n];
  19.             $c2 = $c + 1;
  20.             $values[$n] = $c2;
  21.         }
  22.         $print = "loopCounter: ".$Srp->loopCounter."\n";
  23.         foreach($values as $key => $item) {
  24.             $print = $print."\n".$key.", ".$item;
  25.         }
  26.         return $print;
  27.     }
  28.  
  29.  
  30. ======
  31.  
  32.  
  33.  
  34. (string:1955) loopCounter: 10046
  35.  
  36. 0, 0
  37. 1, 31
  38. 2, 36
  39. 3, 36
  40. 4, 37
  41. 5, 41
  42. 6, 35
  43. 7, 51
  44. 8, 39
  45. 9, 31
  46. 10, 43
  47. 11, 42
  48. 12, 47
  49. 13, 37
  50. 14, 53
  51. 15, 44
  52. 16, 35
  53. 17, 32
  54. 18, 42
  55. 19, 41
  56. 20, 31
  57. 21, 39
  58. 22, 42
  59. 23, 40
  60. 24, 27
  61. 25, 51
  62. 26, 37
  63. 27, 47
  64. 28, 47
  65. 29, 41
  66. 30, 38
  67. 31, 36
  68. 32, 47
  69. 33, 39
  70. 34, 37
  71. 35, 39
  72. 36, 33
  73. 37, 40
  74. 38, 39
  75. 39, 38
  76. 40, 49
  77. 41, 41
  78. 42, 35
  79. 43, 48
  80. 44, 51
  81. 45, 46
  82. 46, 31
  83. 47, 39
  84. 48, 30
  85. 49, 42
  86. 50, 43
  87. 51, 38
  88. 52, 31
  89. 53, 45
  90. 54, 31
  91. 55, 45
  92. 56, 41
  93. 57, 42
  94. 58, 42
  95. 59, 42
  96. 60, 48
  97. 61, 47
  98. 62, 34
  99. 63, 41
  100. 64, 46
  101. 65, 40
  102. 66, 43
  103. 67, 36
  104. 68, 35
  105. 69, 53
  106. 70, 41
  107. 71, 38
  108. 72, 36
  109. 73, 32
  110. 74, 32
  111. 75, 29
  112. 76, 43
  113. 77, 39
  114. 78, 40
  115. 79, 50
  116. 80, 31
  117. 81, 34
  118. 82, 32
  119. 83, 41
  120. 84, 30
  121. 85, 40
  122. 86, 43
  123. 87, 28
  124. 88, 37
  125. 89, 38
  126. 90, 36
  127. 91, 29
  128. 92, 42
  129. 93, 32
  130. 94, 42
  131. 95, 45
  132. 96, 45
  133. 97, 32
  134. 98, 54
  135. 99, 40
  136. 100, 49
  137. 101, 33
  138. 102, 40
  139. 103, 44
  140. 104, 40
  141. 105, 40
  142. 106, 27
  143. 107, 41
  144. 108, 44
  145. 109, 44
  146. 110, 51
  147. 111, 39
  148. 112, 46
  149. 113, 43
  150. 114, 35
  151. 115, 43
  152. 116, 43
  153. 117, 49
  154. 118, 33
  155. 119, 36
  156. 120, 40
  157. 121, 46
  158. 122, 46
  159. 123, 41
  160. 124, 35
  161. 125, 42
  162. 126, 47
  163. 127, 41
  164. 128, 31
  165. 129, 41
  166. 130, 40
  167. 131, 43
  168. 132, 36
  169. 133, 39
  170. 134, 48
  171. 135, 29
  172. 136, 29
  173. 137, 53
  174. 138, 27
  175. 139, 46
  176. 140, 33
  177. 141, 44
  178. 142, 43
  179. 143, 40
  180. 144, 36
  181. 145, 32
  182. 146, 34
  183. 147, 43
  184. 148, 40
  185. 149, 37
  186. 150, 32
  187. 151, 38
  188. 152, 49
  189. 153, 41
  190. 154, 37
  191. 155, 39
  192. 156, 38
  193. 157, 41
  194. 158, 51
  195. 159, 33
  196. 160, 48
  197. 161, 38
  198. 162, 38
  199. 163, 38
  200. 164, 44
  201. 165, 41
  202. 166, 41
  203. 167, 38
  204. 168, 41
  205. 169, 32
  206. 170, 32
  207. 171, 44
  208. 172, 37
  209. 173, 30
  210. 174, 42
  211. 175, 33
  212. 176, 35
  213. 177, 44
  214. 178, 43
  215. 179, 52
  216. 180, 43
  217. 181, 38
  218. 182, 33
  219. 183, 42
  220. 184, 43
  221. 185, 36
  222. 186, 33
  223. 187, 36
  224. 188, 46
  225. 189, 36
  226. 190, 50
  227. 191, 43
  228. 192, 43
  229. 193, 34
  230. 194, 46
  231. 195, 44
  232. 196, 40
  233. 197, 33
  234. 198, 34
  235. 199, 34
  236. 200, 38
  237. 201, 45
  238. 202, 33
  239. 203, 31
  240. 204, 36
  241. 205, 32
  242. 206, 36
  243. 207, 39
  244. 208, 46
  245. 209, 27
  246. 210, 32
  247. 211, 33
  248. 212, 40
  249. 213, 27
  250. 214, 42
  251. 215, 44
  252. 216, 25
  253. 217, 47
  254. 218, 42
  255. 219, 43
  256. 220, 51
  257. 221, 33
  258. 222, 25
  259. 223, 47
  260. 224, 36
  261. 225, 43
  262. 226, 41
  263. 227, 36
  264. 228, 42
  265. 229, 46
  266. 230, 40
  267. 231, 35
  268. 232, 44
  269. 233, 38
  270. 234, 44
  271. 235, 46
  272. 236, 35
  273. 237, 49
  274. 238, 33
  275. 239, 39
  276. 240, 36
  277. 241, 28
  278. 242, 33
  279. 243, 33
  280. 244, 44
  281. 245, 41
  282. 246, 45
  283. 247, 36
  284. 248, 39
  285. 249, 50
  286. 250, 34
  287. 251, 40
  288. 252, 39
  289. 253, 33
  290. 254, 42
  291. 255, 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top