mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 08:14:15 +00:00
* HTTPServer.cpp : true random password
This commit is contained in:
parent
10be150503
commit
97da8e2f2e
@ -782,12 +782,14 @@ namespace http {
|
|||||||
std::string pass; i2p::config::GetOption("http.pass", pass);
|
std::string pass; i2p::config::GetOption("http.pass", pass);
|
||||||
/* generate pass if needed */
|
/* generate pass if needed */
|
||||||
if (needAuth && pass == "") {
|
if (needAuth && pass == "") {
|
||||||
|
uint8_t random[16];
|
||||||
char alnum[] = "0123456789"
|
char alnum[] = "0123456789"
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||||
"abcdefghijklmnopqrstuvwxyz";
|
"abcdefghijklmnopqrstuvwxyz";
|
||||||
pass.resize(16);
|
pass.resize(sizeof(random));
|
||||||
for (size_t i = 0; i < pass.size(); i++) {
|
RAND_bytes(random, sizeof(random));
|
||||||
pass[i] = alnum[rand() % (sizeof(alnum) - 1)];
|
for (size_t i = 0; i < sizeof(random); i++) {
|
||||||
|
pass[i] = alnum[random[i] % (sizeof(alnum) - 1)];
|
||||||
}
|
}
|
||||||
i2p::config::SetOption("http.pass", pass);
|
i2p::config::SetOption("http.pass", pass);
|
||||||
LogPrint(eLogInfo, "HTTPServer: password set to ", pass);
|
LogPrint(eLogInfo, "HTTPServer: password set to ", pass);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user