MCPcopy Create free account
hub / github.com/ClassiCube/ClassiCube / DecodeMachineID

Function DecodeMachineID

src/Platform_Posix.c:1427–1442  ·  view source on GitHub ↗

#######################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* *#########################################################################################################################*/ "b3 c5a-0d9" --> 0xB3C5A0D9

Source from the content-addressed store, hash-verified

1425*#########################################################################################################################*/
1426/* "b3 c5a-0d9" --> 0xB3C5A0D9 */
1427static void DecodeMachineID(char* tmp, int len, cc_uint32* key) {
1428 int hex[MACHINEID_LEN] = { 0 }, i, j, c;
1429 cc_uint8* dst = (cc_uint8*)key;
1430
1431 /* Get each valid hex character */
1432 for (i = 0, j = 0; i < len && j < MACHINEID_LEN; i++)
1433 {
1434 c = PackedCol_DeHex(tmp[i]);
1435 if (c != -1) hex[j++] = c;
1436 }
1437
1438 for (i = 0; i < MACHINEID_LEN / 2; i++)
1439 {
1440 dst[i] = (hex[i * 2] << 4) | hex[i * 2 + 1];
1441 }
1442}
1443
1444#if defined CC_BUILD_LINUX
1445/* Read /var/lib/dbus/machine-id or /etc/machine-id for the key */

Callers 1

GetMachineIDFunction · 0.85

Calls 1

PackedCol_DeHexFunction · 0.85

Tested by

no test coverage detected