gpt4 book ai didi

powershell - PFX 编码并返回到 Powershell 中的 PFX

转载 作者:行者123 更新时间:2023-12-02 16:17:40 25 4
gpt4 key购买 nike

当您将 PFX 转换为 Base64,然后再将其转换回 PFX 时,是否有可能?

$PFX_FILE = get-content 'dummy.pfx' -Encoding Byte
[Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($PFX_FILE)) | Out-File 'dummy.txt'
$BASE64_STR = get-content 'dummy.txt' -Encoding utf8
[Text.Encoding]::Utf8.GetString([Convert]::FromBase64String($BASE64_STR)) | Out-File 'dummy-2.pfx'

第四行的输出毫无疑问是无效的,但我不确定该怎么做。

最佳答案

我在以下位置创建了一个 PFX 证书:C:\temp\PowerShellGraphCert.pfx 并运行了以下命令。我相信这就是您要找的。我将 > PowerShellGraphCert.pfx 转换为 PowerShellGraphCert.txt,然后返回到 dummy-3.pfx。现在 PowerShellGraphCert.pfx = dummy-3.pfx

$PFX_FILE = get-content 'C:\temp\PowerShellGraphCert.pfx' -Encoding Byte
$base64 = [System.Convert]::ToBase64String($PFX_FILE) | Out-File 'C:\temp\PowerShellGraphCertbase64.txt'

$BASE64_STR = get-content 'C:\temp\PowerShellGraphCertbase64.txt'
$filename = 'C:\temp\dummy-3.pfx'
$bytes = [Convert]::FromBase64String($BASE64_STR)
[IO.File]::WriteAllBytes($filename, $bytes)

enter image description here

关于powershell - PFX 编码并返回到 Powershell 中的 PFX,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66239147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com