Created
January 25, 2023 06:00
-
-
Save ihiroky/20f3aae2847f3b55ccd99d201f2e79d5 to your computer and use it in GitHub Desktop.
Revisions
-
ihiroky created this gist
Jan 25, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ // Execute `authy --remote-debugging-port=5858`, access to http://localhost:5858 on a web browser, then paste code below in the dev console. // ref: https://gist.github.com/gboudreau/94bb0c11a6209c82418d01a59d958c93 function hex_to_b32(hex) { let alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"; let bytes = []; for (let i = 0; i < hex.length; i += 2) { bytes.push(parseInt(hex.substr(i, 2), 16)); } let bits = 0; let value = 0; let output = ''; for (let i = 0; i < bytes.length; i++) { value = (value << 8) | bytes[i]; bits += 8; while (bits >= 5) { output += alphabet[(value >>> (bits - 5)) & 31]; bits -= 5; } } if (bits > 0) { output += alphabet[(value << (5 - bits)) & 31]; } return output; } console.clear(); console.warn("Here's your Authy tokens:"); var data = appManager.getModel().map(function (i) { var secretSeed = i.secretSeed; if (typeof secretSeed == 'undefined') { secretSeed = i.encryptedSeed; } var secret = (i.markedForDeletion === false ? i.decryptedSeed : hex_to_b32(secretSeed)); var period = (i.digits === 7 ? 10 : 30); var totp_uri = `otpauth://totp/${encodeURIComponent(i.name)}?secret=${secret}&digits=${i.digits}&period=${period}`; console.group(i.name); console.log('TOTP secret:', secret); console.log('TOTP URI:', totp_uri); console.groupEnd(); return { name: i.name, secret: secret, uri: totp_uri }; });