Created
January 13, 2026 05:27
-
-
Save bivex/14e9815ebfa681bedc0983798945e88b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Copyright (c) 2026 Bivex | |
| * | |
| * Author: Bivex | |
| * Available for contact via email: support@b-b.top | |
| * For up-to-date contact information: | |
| * https://github.com/bivex | |
| * | |
| * Created: 2026-01-13 07:21 | |
| * Last Updated: 2026-01-13 07:27 | |
| * | |
| * Licensed under the MIT License. | |
| * Commercial licensing available upon request. | |
| */ | |
| #include <iostream> | |
| #include <string> | |
| #include <iomanip> | |
| #include <CommonCrypto/CommonDigest.h> | |
| #include <sys/sysctl.h> | |
| #include <cstring> | |
| #include <cstdio> | |
| int main() { | |
| char uuid[256] = {0}; | |
| size_t len = sizeof(uuid); | |
| sysctlbyname("hw.uuid", uuid, &len, NULL, 0); | |
| char serial[256] = {0}; | |
| len = sizeof(serial); | |
| sysctlbyname("hw.serialno", serial, &len, NULL, 0); | |
| char model[256] = {0}; | |
| len = sizeof(model); | |
| sysctlbyname("hw.model", model, &len, NULL, 0); | |
| char data[1024]; | |
| strcpy(data, uuid); | |
| strcat(data, serial); | |
| strcat(data, model); | |
| unsigned char hash[CC_SHA256_DIGEST_LENGTH]; | |
| CC_SHA256((unsigned char*)data, strlen(data), hash); | |
| char hex[65]; | |
| for(int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) { | |
| snprintf(hex + 2 * i, 3, "%02x", hash[i]); | |
| } | |
| hex[64] = '\0'; | |
| std::cout << hex << std::endl; | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment