我尝试生成机器密钥以手动更新web.config,但我需要PowerShell脚本来执行相同的操作。任何人都可以帮助我吗?
答案 0 :(得分:1)
这有用吗?
$key = "2012"
$string = "End of the world is nowhere near us."
$sha256 = New-Object System.Security.Cryptography.HMACSHA256
$sha256.key = [Text.Encoding]::ASCII.GetBytes($key)
$signature = $sha256.ComputeHash([Text.Encoding]::ASCII.GetBytes($string))
$hash = ([Convert]::ToBase64String($signature)) -replace '-',''