Skip to content

Instantly share code, notes, and snippets.

@zhangyoufu
Forked from 1Conan/generator.js
Created February 13, 2019 09:38
Show Gist options
  • Save zhangyoufu/93066c33f317e10b405fdc7aed20d07f to your computer and use it in GitHub Desktop.
Save zhangyoufu/93066c33f317e10b405fdc7aed20d07f 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);
@zhangyoufu
Copy link
Author

from hashlib import sha1
sha1(bytes.fromhex('e6f69faea9e7bf21')[::-1]).hexdigest()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment