Created
June 2, 2020 02:33
-
-
Save sonbyungjun/6e54b2cd3170ff009d1d1099a0681510 to your computer and use it in GitHub Desktop.
Typescript(Javascript) Email Security Function (타입스크립트(자바스크립트) 이메일 블러처리 함수)
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
export function emailSecurity(userEmail: string){ | |
const id = userEmail.split('@')[0]; | |
const mail = userEmail.split('@')[1]; | |
const maskingId = function(id: string) { | |
let splitId = id.substring(0,4); | |
for(let i = 4; i < id.length; i++) { | |
splitId += '*'; | |
} | |
return splitId; | |
}; | |
const maskingMail = function(mail: string){ | |
let splitMail = ''; | |
for(let i = 5; i < mail.length; i++){ | |
splitMail += '*'; | |
} | |
splitMail += mail.substring(mail.length - 5, mail.length); | |
return splitMail; | |
}; | |
userEmail = maskingId(id) + '@' + maskingMail(mail); | |
return userEmail; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment