23

次のコードを実行します。

import Crypto.BCrypt
import Data.ByteString.Lazy.Char8

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

次のコンパイル エラーが発生します。

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.ByteStringなぜ aと a に違いがあるのか​​ わからないので、私は混乱していますByteString

4

1 に答える 1

10

bcrypt docsによると、厳密なバイト文字列を使用する必要があります

import Data.ByteString.Char8

怠け者の代わりに:

import Data.ByteString.Lazy.Char8
于 2013-12-22T20:47:54.740 に答える