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

时间:2018-02-28 06:56:37

标签: haskell

这是我的代码,正在尝试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>",我该怎么做?

1 个答案:

答案 0 :(得分: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>"