Skip to content

Instantly share code, notes, and snippets.

@1Conan
Last active February 13, 2019 09:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 1Conan/ac53cb8316b9d9b3523dfff326f9a4f9 to your computer and use it in GitHub Desktop.
Save 1Conan/ac53cb8316b9d9b3523dfff326f9a4f9 to your computer and use it in GitHub Desktop.
Generator/Apnonce generation script
/**
* genap
* 1Conan
*/
const crypto = require('crypto');
const reverse = require('buffer-reverse');
const hash = crypto.createHash('sha1');
//Data
const random = crypto.randomBytes(8);
//const random = Buffer.from('e6f69faea9e7bf21', 'hex'); //Should give 516f88661d86335bf084ec9c0617333fbe67659c in apnonce for lower devices
let reversed = reverse(random);
const apnonce = crypto.createHash('sha1').update(reversed).digest('hex');
const apnonce7 = crypto.createHash('sha384').update(reversed).digest('hex');
console.log('generator:', '0x' + random.toString('hex'));
console.log('To be hashed:', '0x' + reversed.toString('hex'));
console.log('apnonce: ', apnonce);
console.log('apnonce (iPhone7):', apnonce7);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment