位移(错误:移位量大于类型大小)

时间:2016-11-20 23:40:59

标签: ios swift

大家好,

我对Swift相当新,我遇到了问题,我正在尝试在Swift中实现RFC 6238来生成基于时间的一次性密码,但是我遇到了数组类型和位移的问题:< / p>

    let Input:[UInt8] = [UInt8](hash.base32DecodedString()!.utf8)

        do {

        let ouput = try HMAC(key: Input, variant: .sha1).authenticate(self.toByteArray(self.currentTimeMillis()))

    let offset = Int(ouput[ouput.count - 1]) & 0x0f

_ = (ouput[offset] & 0x7f) << 24) | (ouput[offset + 1] & 0xff) << 16) | (ouput[offset + 2] & 0xff) << 8) | (ouput[offset + 3] & 0xff)

          } catch { }
  

我收到此错误:   错误:移位量大于位类型大小

我的猜测是输出[]没有正确的位移类型,但我找不到合适的类型。

0 个答案:

没有答案