I have googled extensively on this topic, but have not found any method to replicate the following functionality in powershell 5:
Powershell 7 code:
$rsaPrivateKey = [IO.File]::ReadAllText($RSAPrivateKeyFilePath)
$rsa = [System.Security.Cryptography.RSA]::create()
$rsa.ImportFromPem($rsaPrivateKey.ToCharArray())
$signature = $rsa.SignData($dataToSign, [Security.Cryptography.HashAlgorithmName]::SHA256, [Security.Cryptography.RSASignaturePadding]::Pkcs1)
The above contains .NET 5+ features not present in powershell 5. Does anyone know how to replicate the above powershell 7 functionality in powershell 5 (I am forced to use powershell 5)?