///|
let magic_cipher_data : Bytes = b"OrpheanBeholderScryDoubt"

///|
fn bcrypt_hash_raw(password : BytesView, salt : BytesView, cost : Int) -> Bytes {
  let key = bcrypt_key(password)
  let state = new_blowfish_state()
  blowfish_expand_key(state, salt, key.view())
  let rounds = 1 << cost
  for _ in 0..> 24).to_byte())
    out.push((cdata[i] >> 16).to_byte())
    out.push((cdata[i] >> 8).to_byte())
    out.push(cdata[i].to_byte())
  }
  Bytes::from_array(out.view())
}

///|
fn bcrypt_key(password : BytesView) -> Bytes {
  let n = if password.length() > 72 { 72 } else { password.length() }
  Bytes::makei(n + 1, fn(i) { if i < n { password[i] } else { (0).to_byte() } })
}