Skip to content

Instantly share code, notes, and snippets.

@Halo-Michael
Created March 13, 2021 21:32
Show Gist options
  • Save Halo-Michael/d916f6c7253fc16ff7b45ef2e74004a5 to your computer and use it in GitHub Desktop.
Save Halo-Michael/d916f6c7253fc16ff7b45ef2e74004a5 to your computer and use it in GitHub Desktop.
//A7~A9, use SHA1 algorithm to generate apnonce.
unsigned long buf = 0x1111111111111111;
unsigned char result[CC_SHA1_DIGEST_LENGTH];
CC_SHA1(&buf, sizeof(buf), result);
for (int i = 0; i < CC_SHA1_DIGEST_LENGTH; i++)
printf("%02" PRIx32, result[i]);
putchar('\n');
//A10~A11, use SHA384 algorithm, but only take the first 32 bits to generate apnonce.
unsigned long buf = 0x1111111111111111;
unsigned char result[CC_SHA384_DIGEST_LENGTH];
CC_SHA384(&buf, sizeof(buf), result);
for (int i = 0; i < MIN(CC_SHA384_DIGEST_LENGTH, 32); i++)
printf("%02" PRIx32, result[i]);
putchar('\n');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment