Created
May 4, 2022 03:24
-
-
Save kenske/f9ae51348d77c4dc6c275216297a01f7 to your computer and use it in GitHub Desktop.
Export Authy TOTP seeds
This file contains 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 characters
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; | |
} | |
appManager.getModel().forEach(function(i) { | |
console.log(i.name) | |
if(i.markedForDeletion) { | |
return; | |
} | |
let secret = i.decryptedSeed; | |
let period = (i.digits === 7 ? 10 : 30); | |
let 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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment