Skip to content

Commit

Permalink
Make password inputs case insensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
Karthik99999 committed Apr 13, 2024
1 parent 17b971e commit 23834c5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib/generators/rt/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ const characters = [
* Convert password string to array, then
* validates that all characters of the password are valid
* and replaces common unicode characters with the less common ones
* (m,# -> ♂ | f,% -> ♀ | . -> …)
* (# -> ♂ | % -> ♀ | . -> …)
*/
export function sanitizePassword(password: string, length: number): string[] {
password = password.replace(/\s/g, '');
password = password.toUpperCase().replace(/\s/g, '');
if (password.length !== length) throw new Error(`Password must be exactly ${length} characters long`);
const sanitized: string[] = [];
for (let char of password) {
char = char.replace(/\./g, '…').replace(/m|#/g, '♂').replace(/f|%/g, '♀');
char = char.replace(/\./g, '…').replace(/#/g, '♂').replace(/%/g, '♀');

if (characters.includes(char)) {
sanitized.push(char);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/generators/rtdx/read.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { checksum, crc32, RNG, symbols } from './utils';
import Data from './data';

function sanitizePassword(password: string): string[] {
const split = password.replace(/\s/g, '').match(/.{2}/g);
const split = password.toLowerCase().replace(/\s/g, '').match(/.{2}/g);
if (split?.length !== 30) throw new Error('Password must be exactly 30 symbols long');
for (let symbol of split) {
if (!symbols.includes(symbol)) {
Expand Down
4 changes: 2 additions & 2 deletions src/routes/(rt)/rt-sosconverter/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@

<h4>Rescue Team SOS Converter</h4>
<ul>
<li>For the male sign (♂), you may use "m" or "#"</li>
<li>For the female sign (♀), you may use "f" or "%"</li>
<li>For the male sign (♂), you may use "#"</li>
<li>For the female sign (♀), you may use "%"</li>
<li>For the ellipsis (…), you may use "."</li>
</ul>

Expand Down

0 comments on commit 23834c5

Please # to comment.