@@ -1310,33 +1310,6 @@ func Rand(min, max int) int {
1310
1310
return r .Intn (max + 1 - min ) + min
1311
1311
}
1312
1312
1313
- // RandomBytes random_bytes()
1314
- func RandomBytes (length int ) ([]byte , error ) {
1315
- bs := make ([]byte , length )
1316
- _ , err := crand .Read (bs )
1317
- if err != nil {
1318
- return nil , err
1319
- }
1320
-
1321
- return bs , nil
1322
- }
1323
-
1324
- // RandomInt random_int()
1325
- func RandomInt (min , max int ) (int , error ) {
1326
- if min > max {
1327
- panic ("argument #1 must be less than or equal to argument #2" )
1328
- }
1329
-
1330
- if min == max {
1331
- return min , nil
1332
- }
1333
- nb , err := crand .Int (crand .Reader , big .NewInt (int64 (max + 1 - min )))
1334
- if err != nil {
1335
- return 0 , err
1336
- }
1337
- return int (nb .Int64 ()) + min , nil
1338
- }
1339
-
1340
1313
// Round round()
1341
1314
func Round (value float64 , precision int ) float64 {
1342
1315
p := math .Pow10 (precision )
@@ -1458,6 +1431,35 @@ func IsNan(val float64) bool {
1458
1431
return math .IsNaN (val )
1459
1432
}
1460
1433
1434
+ //////////// CSPRNG Functions ////////////
1435
+
1436
+ // RandomBytes random_bytes()
1437
+ func RandomBytes (length int ) ([]byte , error ) {
1438
+ bs := make ([]byte , length )
1439
+ _ , err := crand .Read (bs )
1440
+ if err != nil {
1441
+ return nil , err
1442
+ }
1443
+
1444
+ return bs , nil
1445
+ }
1446
+
1447
+ // RandomInt random_int()
1448
+ func RandomInt (min , max int ) (int , error ) {
1449
+ if min > max {
1450
+ panic ("argument #1 must be less than or equal to argument #2" )
1451
+ }
1452
+
1453
+ if min == max {
1454
+ return min , nil
1455
+ }
1456
+ nb , err := crand .Int (crand .Reader , big .NewInt (int64 (max + 1 - min )))
1457
+ if err != nil {
1458
+ return 0 , err
1459
+ }
1460
+ return int (nb .Int64 ()) + min , nil
1461
+ }
1462
+
1461
1463
//////////// Directory/Filesystem Functions ////////////
1462
1464
1463
1465
// Stat stat()
@@ -2105,7 +2107,7 @@ func VersionCompare(version1, version2, operator string) bool {
2105
2107
}
2106
2108
} else if ! (p1 [0 ] >= '0' && p1 [0 ] <= '9' ) && ! (p2 [0 ] >= '0' && p2 [0 ] <= '9' ) { // all digit
2107
2109
compare = special (p1 , p2 )
2108
- } else { // part is digit
2110
+ } else { // part is digit
2109
2111
if p1 [0 ] >= '0' && p1 [0 ] <= '9' { // is digit
2110
2112
compare = special ("#N#" , p2 )
2111
2113
} else {
0 commit comments