Skip to content

recovery key generation method #67

@nblog

Description

@nblog

In the "Recovery Key" section,there is no mention of how to generate it, so I'll add the method for that,It comes from one of the tools I analyzed.

std::srand(static_cast<std::uint32_t>(std::time(0)));

std::array<uint8_t, 16> tmpvalue = { 0 };

for (size_t i = 0; i < 16; i++)
{
	tmpvalue[i] = uint8_t(int(double(std::rand()) * 0.000030517578125 * 255.0 + 0.0));
}

std::array<std::string, 8> blocks;

for (size_t i = 0; i < 8; i++)
{
	char szBuffer[20] = { 0 };
	sprintf(szBuffer, "%06d", ((uint16_t*)(tmpvalue.data()))[i] * 11);
	blocks[i] = szBuffer;
}

return blocks[0] 
	+ "-" + blocks[1]
	+ "-" + blocks[2]
	+ "-" + blocks[3]
	+ "-" + blocks[4]
	+ "-" + blocks[5]
	+ "-" + blocks[6]
	+ "-" + blocks[7];

@joachimmetz ,i hope this helps.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions