PowerShell 十六进制到字符串的转换 [英] PowerShell hex to string conversion

查看:62
本文介绍了PowerShell 十六进制到字符串的转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要帮助将文本文件中包含的所有十六进制字符转换为字符串或 ASCII.十六进制字符以标准格式

Need help to convert all hex characters contained in a text file to string or ASCII. Hex characters appear in a standard format of

user1 domain1 7374726f6e6770617373776f7264403130                                               
user2 domain2 7374726f6e6770617373776f7264403120

转换后应该显示为

user1 domain1 strongpassword@10

文本文件包含多个密码,全部排成一行

the text file contains the multiple passwords, all arranged in a row

推荐答案

Get-Content file.txt | Foreach-Object{

    $user,$domain,$pass = $_.Split()

    $pass = for($i=0; $i -lt $pass.length; $i+=2)
    {
       [char][int]::Parse($pass.substring($i,2),'HexNumber')
    }

    $user,$domain,(-join $pass) -join ' '
}

这篇关于PowerShell 十六进制到字符串的转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆