Skip to content

Instantly share code, notes, and snippets.

@JanWerder
Last active November 8, 2021 11:05
Show Gist options
  • Select an option

  • Save JanWerder/a50f1113fde80dbdc78fc503fe767d20 to your computer and use it in GitHub Desktop.

Select an option

Save JanWerder/a50f1113fde80dbdc78fc503fe767d20 to your computer and use it in GitHub Desktop.
// Decodes a BOBF binary key to a HEX String
decodeBOBFKey: function (str) {
const raw = atob(str);
let result = '';
for (let i = 0; i < raw.length; i++) {
const hex = raw.charCodeAt(i).toString(16);
result += (hex.length === 2 ? hex : '0' + hex);
}
return result.toUpperCase();
}
//Example: base64ToHex("AFBWuTv8HtuFpXoO4hsXtQ==") --> '005056B93BFC1EDB85A57A0EE21B17B5'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment