hex-to-string.ps1

  1. if (!$args[0]) {
  2. Write-Host "Please enter content"
  3. exit
  4. }
  5. $hexStr = $args[0].toString()
  6. $bytes = @()
  7. for($i = 0; $i -lt $hexStr.length; $i += 2) {
  8. $e = $hexStr[$i] + $hexStr[$i + 1]
  9. $bytes += [System.Convert]::ToByte($e, 16)
  10. }
  11. [System.Text.Encoding]::Default.GetString($bytes)

parse-mdc-file.ps1

  1. if (!$args[0]) {
  2. Write-Host "please enter data directory"
  3. return
  4. }
  5. Get-ChildItem -Path $args[0] -Force -Name | ForEach-Object {
  6. $name = ($_ -split '\.')[1]
  7. hex-to-string.ps1 $name
  8. } | Select-Object -Unique

string-to-hex.ps1

  1. if (!$args[0]) {
  2. Write-Host "Please enter content"
  3. exit
  4. }
  5. $str = $args[0].toString()
  6. $hex = [System.BitConverter]::ToString([System.Text.Encoding]::Default.GetBytes($str))
  7. $hex -replace "-",""