refactor(otp-generator): coerce lowercase secret characters to uppercase

This commit is contained in:
Corentin Thomasset 2023-03-26 22:40:43 +02:00 committed by Corentin THOMASSET
parent f3b1863f09
commit 7c40539ef9
3 changed files with 7 additions and 2 deletions

View file

@ -26,6 +26,7 @@ function base32toHex(base32: string) {
const base32Chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567';
const bits = base32
.toUpperCase() // Since base 32, we coerce lowercase to uppercase
.replace(/=+$/, '')
.split('')
.map((value) => base32Chars.indexOf(value).toString(2).padStart(5, '0'))