{"id":28515999,"url":"https://github.com/keygen-sh/example-cpp-cryptographic-license-files","last_synced_at":"2025-07-05T17:31:35.333Z","repository":{"id":53872988,"uuid":"521772354","full_name":"keygen-sh/example-cpp-cryptographic-license-files","owner":"keygen-sh","description":"Example of verifying cryptographically signed and encrypted license files using C++, OpenSSL, Ed25519 and AES-256-GCM. ","archived":false,"fork":false,"pushed_at":"2023-12-08T16:22:54.000Z","size":107,"stargazers_count":11,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-30T00:38:29.101Z","etag":null,"topics":["aes-256","aes-256-gcm","aes-gcm","ed25519","license-files","license-keys","licensing","openssl"],"latest_commit_sha":null,"homepage":"https://keygen.sh","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/keygen-sh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-05T20:47:45.000Z","updated_at":"2025-04-02T01:53:39.000Z","dependencies_parsed_at":"2023-02-10T10:31:05.283Z","dependency_job_id":null,"html_url":"https://github.com/keygen-sh/example-cpp-cryptographic-license-files","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/keygen-sh/example-cpp-cryptographic-license-files","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keygen-sh%2Fexample-cpp-cryptographic-license-files","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keygen-sh%2Fexample-cpp-cryptographic-license-files/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keygen-sh%2Fexample-cpp-cryptographic-license-files/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keygen-sh%2Fexample-cpp-cryptographic-license-files/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/keygen-sh","download_url":"https://codeload.github.com/keygen-sh/example-cpp-cryptographic-license-files/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/keygen-sh%2Fexample-cpp-cryptographic-license-files/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263778489,"owners_count":23509995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aes-256","aes-256-gcm","aes-gcm","ed25519","license-files","license-keys","licensing","openssl"],"created_at":"2025-06-09T03:31:39.247Z","updated_at":"2025-07-05T17:31:35.328Z","avatar_url":"https://github.com/keygen-sh.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Example C++ Cryptographic License Files\n\nThis is an example of how to verify and decrypt [cryptographic license files](https://keygen.sh/docs/api/cryptography/#cryptographic-lic)\nin C++, using OpenSSL, Ed25519 verification and AES-256-GCM decryption.\n\nThis example implements the `aes-256-gcm+ed25519` algorithm.\n\n## Running the example\n\nFirst up, add an environment variable containing your public key:\n\n```bash\n# Your Keygen account's Ed25519 public key.\nexport KEYGEN_PUBLIC_KEY=\"e8601e48b69383ba520245fd07971e983d06d22c4257cfd82304601479cee788\"\n\n# A license key.\nexport KEYGEN_LICENSE_KEY=\"E1FBA2-5488D8-8AC81A-53157E-01939A-V3\"\n```\n\nYou can either run each line above within your terminal session before\nstarting the app, or you can add the above contents to your `~/.bashrc`\nfile and then run `source ~/.bashrc` after saving the file.\n\nNext, on macOS, ensure OpenSSL v1.1.1 is installed. If needed, install\nusing `homebrew`:\n\n```bash\nbrew install openssl@1.1.1\n```\n\nThen compile the source using `g++`:\n\n```bash\ng++ main.cpp -o bin.out \\\n  -std=c++17 \\\n  -lssl \\\n  -lcrypto \\\n  -I /usr/local/opt/openssl/include \\\n  -L /usr/local/opt/openssl/lib \\\n  -I include/**/*.c\n```\n\nThen run the script, passing in a path to a license file:\n\n```bash\n./bin.out /etc/keygen/license.lic\n```\n\nAlternatively, you can prefix the below command with env variables, e.g.:\n\n```bash\nKEYGEN_PUBLIC_KEY=\"e8601e48b69383ba520245fd07971e983d06d22c4257cfd82304601479cee788\" \\\n  KEYGEN_LICENSE_KEY=\"E1FBA2-5488D8-8AC81A-53157E-01939A-V3\" \\\n  ./bin.out examples/license.lic\n```\n\nYou should see output indicating that the license file is valid, with its\ndecrypted dataset:\n\n```\n[INFO] Importing...\n[OK] License file successfully imported!\n[INFO] Verifying...\n[OK] License file successfully verified!\n[INFO] Decrypting...\n[OK] License file successfully decrypted!\n[INFO] Parsing...\n[OK] License successfully parsed!\nname=C++ Example License\nkey=E1FBA2-5488D8-8AC81A-53157E-01939A-V3\nstatus=ACTIVE\nlast_validated_at=null\nexpires_at=2025-01-01T00:00:00.000Z\ncreated_at=2022-08-05T19:27:36.492Z\nupdated_at=2022-08-05T19:27:36.492Z\nentitlements=[FEATURE_ENTITLEMENT_C,FEATURE_ENTITLEMENT_B,FEATURE_ENTITLEMENT_A]\nproduct=3bf34475-dfb4-42d8-a763-a2c89507f16d\npolicy=5ba80f5e-c3a6-4f38-bc0b-bd12053cef66\nuser=2068992b-f98f-4efc-95fd-687dbd0c868c\n```\n\nIf the license file fails to decrypt, ensure that you're providing the correct\nlicense key via `KEYGEN_LICENSE_KEY`. License files are encrypted with their\nlicense's key, so an incorrect license key will fail to decrypt.\n\n## Questions?\n\nReach out at [support@keygen.sh](mailto:support@keygen.sh) if you have any\nquestions or concerns!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeygen-sh%2Fexample-cpp-cryptographic-license-files","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkeygen-sh%2Fexample-cpp-cryptographic-license-files","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkeygen-sh%2Fexample-cpp-cryptographic-license-files/lists"}