Releases: virtualox/Get-RandomHex.ps1
Releases · virtualox/Get-RandomHex.ps1
Get-RandomHex.ps1
Get-RandomHex.ps1
The latest version of Get-RandomHex.ps1, a PowerShell script designed to generate cryptographically secure random hexadecimal strings.
Features
- Cryptographically Secure Random Number Generation: Utilizes the
System.Security.Cryptography.RandomNumberGenerator
class to ensure high entropy and security. - Customizable Bit Length: Generate hexadecimal strings of any specified bit length. Defaults to 256 bits if no length is specified.
- Compatibility: Designed for compatibility with multiple .NET versions using
RandomNumberGenerator.Create()
. - Ease of Use: Accepts the
-BitLength
parameter at both the script and function levels for flexibility. - Code-Signed with EV Certificate: This script is code-signed with an Extended Validation (EV) certificate to ensure authenticity and integrity.
Code Signing
The script is code-signed with an EV certificate to provide:
- Authenticity: Verifies that the script originates from a trusted source.
- Integrity: Ensures the code has not been altered since it was signed.
You can verify the code signature using the following PowerShell command:
Get-AuthenticodeSignature .\Get-RandomHex.ps1
Usage
Running the Script Directly
To generate a hex string without specifying a bit length (defaults to 256 bits):
.\Get-RandomHex.ps1
To generate a hex string in PowerShell based on a desired bit length:
.\Get-RandomHex.ps1 -BitLength 128
Importing the Function into Your Session
You can import the function and use it directly in your PowerShell session:
# Import the function
. .\Get-RandomHex.ps1
# Generate a 256-bit random hexadecimal string
Get-RandomHexString
# Generate a 128-bit random hexadecimal string
Get-RandomHexString -BitLength 128
Installation
- Download the
Get-RandomHex.ps1
script from this release. - Verify the code signature to ensure the script's integrity.
- Run the script directly or import the function into your PowerShell session.
Example
Generate a 64-bit hexadecimal string:
.\Get-RandomHex.ps1 -BitLength 64
Sample output:
e4f8c2d9a1b3c4d5