mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-17 21:47:37 +00:00
Get random separately
This commit is contained in:
parent
46ce765860
commit
2087e47300
@ -33,7 +33,7 @@ int fork_no_orphan() {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int gen_rand_str(char *buf, int len, const void *seed_buf, bool varlen) {
|
mt19937_64 &get_rand(const void *seed_buf) {
|
||||||
static mt19937_64 gen([&] {
|
static mt19937_64 gen([&] {
|
||||||
mt19937_64::result_type seed;
|
mt19937_64::result_type seed;
|
||||||
if (seed_buf == nullptr) {
|
if (seed_buf == nullptr) {
|
||||||
@ -45,6 +45,11 @@ int gen_rand_str(char *buf, int len, const void *seed_buf, bool varlen) {
|
|||||||
}
|
}
|
||||||
return seed;
|
return seed;
|
||||||
}());
|
}());
|
||||||
|
return gen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int gen_rand_str(char *buf, int len, bool varlen) {
|
||||||
|
auto gen = get_rand();
|
||||||
|
|
||||||
if (len == 0)
|
if (len == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <bitset>
|
#include <bitset>
|
||||||
|
#include <random>
|
||||||
|
|
||||||
#include <base-rs.hpp>
|
#include <base-rs.hpp>
|
||||||
|
|
||||||
@ -159,7 +160,8 @@ void init_argv0(int argc, char **argv);
|
|||||||
void set_nice_name(const char *name);
|
void set_nice_name(const char *name);
|
||||||
uint32_t binary_gcd(uint32_t u, uint32_t v);
|
uint32_t binary_gcd(uint32_t u, uint32_t v);
|
||||||
int switch_mnt_ns(int pid);
|
int switch_mnt_ns(int pid);
|
||||||
int gen_rand_str(char *buf, int len, const void *seed_buf = nullptr, bool varlen = true);
|
std::mt19937_64 &get_rand(const void *seed_buf = nullptr);
|
||||||
|
int gen_rand_str(char *buf, int len, bool varlen = true);
|
||||||
std::string &replace_all(std::string &str, std::string_view from, std::string_view to);
|
std::string &replace_all(std::string &str, std::string_view from, std::string_view to);
|
||||||
std::vector<std::string> split(const std::string &s, const std::string &delims);
|
std::vector<std::string> split(const std::string &s, const std::string &delims);
|
||||||
std::vector<std::string_view> split_ro(std::string_view, std::string_view delims);
|
std::vector<std::string_view> split_ro(std::string_view, std::string_view delims);
|
||||||
|
@ -209,7 +209,7 @@ void MagiskInit::parse_config_file() {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
gen_rand_str(nullptr, 0, &seed);
|
get_rand(&seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ROOTMIR MIRRDIR "/system_root"
|
#define ROOTMIR MIRRDIR "/system_root"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user