我正在 Fsharp 中创建 RSA pki 并尝试加载私钥:
let getRsa () =
let rsa = RSA.Create()
let privateKey = getPrivateKey()
let bytesRead = ref 0
match privateKey with
| Some priv ->
rsa.ImportRSAPrivateKey(source = priv, bytesRead = bytesRead)
Some rsa
| None -> None
不幸的是,这不会飞,因为:
This expression was expected to have type 'ReadOnlySpan' but here has type 'byte []' F# Compiler(1)
有没有办法转换成ReadOnlySpan?
最佳答案
您可以通过将字节数组传递到 relevant constructor 来创建 ReadOnlySpan
:
System.ReadOnlySpan(priv)
关于arrays - 有没有一种简单的方法可以在 Fsharp 中将 byte [] 转换为 ReadOnlySpan<byte> ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63676224/