'use strict'; var base64 = require('urlsafe-base64'); function log(n, x) { console.log(n, x.length, Buffer.isBuffer(x) ? base64.encode(x) : x); } /*var e = base64.decode('uNCkWiNYzKTnBN9ji3-qWAAAAAoCYTGH' + 'OqYFz-0in3dpb-VE2GfBngkaPy6bZus_' + 'qLF79s6zQyTSsA0iLOKyd3JqVIwprNzV' + 'atRCWZGUx_qsFbJBCQu62RqQuR2d'); */ var h1 = base64.decode('DGv6ra1nlYgDCS1FRnbzlwAAxowA'); log('h1', h1); var dh = base64.decode('BP4z9KsN6nGRTbVYI_c7VJSPQTBtkgcy27mlmlMoZIIgDll6e3vCYLocInmYWAmS6TlzAC8wEqKK6PBru3jl7A8'); log('dh', dh); h1.writeUIntBE(dh.length, 20, 1); var c = base64.decode('Ig1VvoJvrVBFhclGlx4G2FuProCVzJY04Lg5vUP2LeswtWoBGHGoYXUzAwuxQGRGxoNbh8BROK3gmJ0'); log('c', c); log('h2', Buffer.concat([h1, dh])); log('m', Buffer.concat([h1, dh, c])); var e = base64.decode('uNCkWiNYzKTnBN9ji3-qWAAAAAoAhzqmBc_tIp93aW_lRNhnwZ4JGj8um2brP6ixe_bOs0Mk0rANIizisndyalSMKazc1WrUQlmRlMf6rBWyQQkLutkakLkdnQ'); log('y', e); log('x', Buffer.concat([base64.decode('uNCkWiNYzKTnBN9ji3-qW'), Buffer.from([0, 0, 0, 10, 2, 'a'.charCodeAt(0), '1'.charCodeAt(0)]), base64.decode('hzqmBc_tIp93aW_lRNhnwZ4JGj8um2brP6g'), base64.decode('sXv2zrNDJNKwDSIs4rJ3cmpUjCms3NVq1EI'), base64.decode('WZGUx_qsFbJBCQu62RqQuR2d') ])); var salt = e.slice(0, 16); log('salt', salt); var rs = e.readUIntBE(16, 4); log('rs', rs); var idsz = e.readUIntBE(20, 1); var id = e.slice(21, 21 + idsz); log('id', id); console.log('id', id.toString()); log('header', e.slice(0, 21 + idsz)); log('main', e.slice(21 + idsz, e.length - 16)); log('tag', e.slice(e.length - 16));