Skip to content

Commit

Permalink
encryption regex
Browse files Browse the repository at this point in the history
  • Loading branch information
prayanshchh committed Nov 5, 2024
1 parent 07516b6 commit d513a7b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/utilities/encryption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ export function encryptEmail(email: string): string {
throw new Error("Empty or invalid email input.");
}

const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
throw new Error("Invalid email format.");
}

if (!encryptionKey) {
throw new Error("Encryption key is not defined.");
} else if (encryptionKey.length !== 64 || !isValidHex(encryptionKey)) {
Expand Down

0 comments on commit d513a7b

Please sign in to comment.