首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法将预期的类型`Data.ByteString.Internal.ByteString与实际的类型`ByteString匹配

无法将预期的类型`Data.ByteString.Internal.ByteString与实际的类型`ByteString匹配
EN

Stack Overflow用户
提问于 2013-12-23 04:47:55
回答 1查看 5.9K关注 0票数 23

运行以下代码:

代码语言:javascript
复制
import Crypto.BCrypt
import Data.ByteString.Lazy.Char8

main = do
  maybe_pwhash <- hashPasswordUsingPolicy slowerBcryptHashingPolicy (pack "hunter2")
  print $ maybe_pwhash

我得到以下编译错误:

代码语言:javascript
复制
test.hs:5:70:
    Couldn't match expected type `Data.ByteString.Internal.ByteString'
                with actual type `ByteString'
    In the return type of a call of `pack'
    In the second argument of `hashPasswordUsingPolicy', namely
      `(C.pack "hunter2")'
    In a stmt of a 'do' block:
      maybe_pwhash <- hashPasswordUsingPolicy
                        slowerBcryptHashingPolicy (pack "hunter2")

我很困惑,因为我不明白为什么Data.ByteString.Internal.ByteStringByteString之间有区别。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-23 04:47:55

根据bcrypt docs,您应该使用严格的字节字符串

代码语言:javascript
复制
import Data.ByteString.Char8

而不是懒惰的人:

代码语言:javascript
复制
import Data.ByteString.Lazy.Char8
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20733924

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档