Refactor encodePassword function to improve password encoding

This commit is contained in:
Douglas Barone 2023-12-15 17:25:18 -04:00
parent 50c33eb172
commit 8ce77400d6

View File

@ -1,11 +1,12 @@
export function encodePassword(password: string): string { export function encodePassword(password: string): string {
let newPassword = '' let newPassword = ''
password = '"' + password + '"'
for (let i = 0; i < password.length; i++) { for (let i = 0; i < password.length; i++) {
newPassword += String.fromCharCode( newPassword += String.fromCharCode(
password.charCodeAt(i) & 0xff, password.charCodeAt(i) & 0xff,
(password.charCodeAt(i) >>> 8) & 0xff (password.charCodeAt(i) >>> 8) & 0xff
) )
} }
return newPassword
return `"${newPassword}"`
} }