{"id":48577880,"url":"https://github.com/virtualox/get-randomhex","last_synced_at":"2026-04-08T16:03:46.534Z","repository":{"id":146963231,"uuid":"197593868","full_name":"virtualox/Get-RandomHex","owner":"virtualox","description":"Adjustable Random Hex String Generator.","archived":false,"fork":false,"pushed_at":"2023-10-21T06:43:14.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-10-21T07:25:47.601Z","etag":null,"topics":["cryptography","function","hex","hexadecimal","powershell","powershell-scripting","powershell-scripts","random-key-generator","rngcryptoserviceprovider"],"latest_commit_sha":null,"homepage":"","language":"PowerShell","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/virtualox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["virtualox"],"custom":["https://paypal.me/VirtualOx"]}},"created_at":"2019-07-18T13:36:23.000Z","updated_at":"2023-10-21T06:15:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"b16db7b3-b141-408e-be19-73b953b7b21b","html_url":"https://github.com/virtualox/Get-RandomHex","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"purl":"pkg:github/virtualox/Get-RandomHex","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualox%2FGet-RandomHex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualox%2FGet-RandomHex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualox%2FGet-RandomHex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualox%2FGet-RandomHex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/virtualox","download_url":"https://codeload.github.com/virtualox/Get-RandomHex/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/virtualox%2FGet-RandomHex/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31562697,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"ssl_error","status_checked_at":"2026-04-08T14:31:17.202Z","response_time":54,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["cryptography","function","hex","hexadecimal","powershell","powershell-scripting","powershell-scripts","random-key-generator","rngcryptoserviceprovider"],"created_at":"2026-04-08T16:03:46.349Z","updated_at":"2026-04-08T16:03:46.519Z","avatar_url":"https://github.com/virtualox.png","language":"PowerShell","readme":"# Get-RandomHex\n\n**`Get-RandomHex.ps1`** is a PowerShell script designed to generate cryptographically secure random hexadecimal strings. This is useful for creating keys, tokens, or any scenario where high-entropy random data is required. A common use case is generating a 16-byte (128-bit) key, which aligns with the recommended minimum entropy for session IDs [as per OWASP guidelines](https://owasp.org/www-community/vulnerabilities/Insufficient_Session-ID_Length).\n\n## Features\n\n- Generates random hexadecimal strings based on a specified bit length.\n- Utilizes cryptographically secure random number generation methods.\n- Compatible with multiple .NET versions due to the use of `RandomNumberGenerator.Create()`.\n- Accepts the `-BitLength` parameter at both the script and function levels.\n- Handles bit lengths not divisible by 8 by appropriately trimming the output.\n\n## Usage\n\n### Running the Script Directly\n\nTo generate a hex string without specifying a bit length (defaults to 256 bits):\n\n```powershell\n.\\Get-RandomHex.ps1\n```\n\nTo generate a hex string in PowerShell based on a desired bit length:\n```powershell\n.\\Get-RandomHex.ps1 -BitLength 128\n```\n\n## Importing the Function into Your Session\nYou can import the function and use it directly in your PowerShell session:\n\n- Import the function\n```powershell\n. .\\Get-RandomHex.ps1\n```\n- Generate a 256-bit random hexadecimal string\n```powershell\nGet-RandomHexString\n```\n- Generate a 128-bit random hexadecimal string\n```powershell\nGet-RandomHexString -BitLength 128\n```\n\n## Installation\n1. **Clone** or **download** this repository to your local machine.\n2. **Run the script directly** or **import the function** into your PowerShell session.\n    - Running the script directly:\n    ```powershell\n    .\\Get-RandomHex.ps1\n    ```\n    - Importing the function:\n    ```powershell\n    . .\\Get-RandomHex.ps1  # Note the dot and space before the script path\n    ```\n\n## Contribution\nContributions are welcome! Please open an issue or submit a pull request for any improvements or fixes. Before submitting a PR, ensure that you've tested your changes and updated any necessary documentation.\n","funding_links":["https://github.com/sponsors/virtualox","https://paypal.me/VirtualOx"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualox%2Fget-randomhex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvirtualox%2Fget-randomhex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvirtualox%2Fget-randomhex/lists"}