SipHash24 Key"类型太大"

时间:2015-10-18 03:23:22

标签: c hash cryptography

我被告知要使用Siphash键

  

24 64 6d 71 33 45 30 31 63 2f 6d 69 37 33 9d 19

我正在尝试使用OpenBSD上的SipHash24_Init。

我有以下全球:

const SIPHASH_KEY COMP_SIPHASH_KEY = 0x24646d7133453031632f6d6937339d19;

使用方式如下:

SIPHASH_CTX ctx;
SipHash24_Init(&ctx, &COMP_SIPHASH_KEY);

我会发布更多内容,但它很复杂,而且我认为它并不相关

但是我在定义/声明上遇到以下编译器错误:

error: integer constant is too large for its type
error: invalid initializer

1 个答案:

答案 0 :(得分:1)

所以考虑到我最近在C中的有限练习,我认为你应该做的事情如下:

 if ($scope.data.weightunit === 'kg'){
      $scope.data.minWeight=30;
      $scope.data.maxWeight=140;
    } else {
      $scope.data.minWeight=65;
      $scope.data.maxWeight=310;
    }
  if (sessionService.get('userWeight')) {$scope.data.userweight = parseInt(sessionService.get('userWeight')) } else {$scope.data.userweight = 70};
  if (sessionService.get('userLevel')) {$scope.data.levelvalue = parseInt(sessionService.get('userLevel')) } else {$scope.data.levelvalue = 5};

  $scope.changeMinMax = function () {
    if ($scope.data.weightunit === 'kg'){
      $scope.data.minWeight=30;
      $scope.data.maxWeight=140;
    } else {
      $scope.data.minWeight=65;
      $scope.data.maxWeight=310;
    }
  }
  $scope.convertWeightInput = function () {
    if ($scope.data.weightunit === 'kg'){
      $scope.data.userweight = parseFloat(Math.round(lbs2kg($scope.data.userweight)));
      console.log(typeof $scope.data.userweight);
      console.log($scope.data.userweight);
    } else {
      $scope.data.userweight = parseFloat(Math.round(kg2lbs($scope.data.userweight)));
      console.log(typeof $scope.data.userweight);
      console.log($scope.data.userweight);
    }
  }

因为SIPHASH_CTX ctx; SIPHASH_KEY key; key.k0 = bswap_64(0x24646d7133453031); key.k1 = bswap_64(0x632f6d6937339d19); SipHash24_Init(&ctx, &key); 似乎被定义为

SIPHASH_KEY

我在这里使用typedef struct { uint64_t k0; uint64_t k1; } SIPHASH_KEY; 库来反转long值中的字节,因为<byteswap.h>k0应该被编码为小端值。