字符串从Crypto.PubKey.Ed25519的PublicKey中提取

问题描述 投票:1回答:1

这是我的代码,正在尝试GHCI

import Crypto.PubKey.Ed25519
import Crypto.Error
import Data.ByteString.Char8

str :: String;str = "hellohellohellohelloǰello%$*/.õƲ"

getSecretKey seedString = throwCryptoError (secretKey (pack seedString))

getPublicKey secretKey = toPublic secretKey

sk = getSecretKey str

pk = getPublicKey sk

这里pk的价值是PublicKey "\134M\130F\142\CAN\190\v,\228\190\232v\171\243]5\CAN\t\211\151\DC1]\188\t\206\233k\190\237\218>"

我想提取字符串部分"\134M\130F\142\CAN\190\v,\228\190\232v\171\243]5\CAN\t\211\151\DC1]\188\t\206\233k\190\237\218>",我该怎么办?

haskell
1个回答
0
投票
(Data.ByteArray.convert  pk)::ByteString 

这从"\134M\130F\142\CAN\190\v,\228\190\232v\171\243]5\CAN\t\211\151\DC1]\188\t\206\233k\190\237\218>"中提取ByteString(PublicKey "\134M\130F\142\CAN\190\v,\228\190\232v\171\243]5\CAN\t\211\151\DC1]\188\t\206\233k\190\237\218>"

© www.soinside.com 2019 - 2024. All rights reserved.