def core_hmac_sha1(key, data)
      bkey = str2binb(key)
      bkey = core_sha1(bkey, key.length * $chrsz) if bkey.length > 16

      ipad = Array.new(16, 0)
      opad = Array.new(16, 0)
      # for(var i = 0; i < 16; i++)
      i = 0
      while i < 16
        ipad[i] = (bkey[i] || 0) ^ 0x36363636
        opad[i] = (bkey[i] || 0) ^ 0x5C5C5C5C
        i += 1
      end

      hash = core_sha1((ipad + str2binb(data)), 512 + data.length * $chrsz)
      core_sha1((opad + hash), 512 + 160)
    end
def core_hmac_sha1(key, data)
      bkey = str2binb(key)
      bkey = core_sha1(bkey, key.length * $chrsz) if bkey.length > 16

      ipad = Array.new(16, 0)
      opad = Array.new(16, 0)
      # for(var i = 0; i < 16; i++)
      i = 0
      while i < 16
        ipad[i] = (bkey[i] || 0) ^ 0x36363636
        opad[i] = (bkey[i] || 0) ^ 0x5C5C5C5C
        i += 1
      end

      hash = core_sha1((ipad + str2binb(data)), 512 + data.length * $chrsz)
      core_sha1((opad + hash), 512 + 160)
    end
Calculate the HMAC-SHA1 of a key and some data