Skip to content

Commit

Permalink
added docs cryptography feature
Browse files Browse the repository at this point in the history
  • Loading branch information
novcmbro committed Jun 16, 2024
1 parent ef5c544 commit a70e5b9
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 2 deletions.
20 changes: 20 additions & 0 deletions docs/en/feature-cryptography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Decoder - 2. Features
## 2.3. Cryptography
### cryptography.js
Encryption replaces each letter by its corresponding term and decryption replaces each term by its corresponding letter. Letters and terms entries can be found in [`cryptographyEntries.js`](/src/js/cryptographyEntries.js). Cryptography has validations and alert to inform invalid input text. When valid, input text is cleared and output text is shown with copy option. When invalid, the output is cleared and hidden.

### Method `cryptography`
- `cryptography.data`: Returns both cryptography keys and its result according to the `target` button passed as parameter, which can be *encrypt* or *decrypt*. Reverts entries if *decrypt* is the target. Replaces input text using the cryptography keys as `regEx` of `replace` method to get the output text.
- `cryptography.validate`: Returns `true` if input text is valid or `false` if invalid, according to `target` parameter's button.
- `validations`: Sub-method of conditions, each one returning `true` or an error message. Sets the error message and alerts it to screen reader, or restores the initial message and removes the alert.
- `cryptography.submit`: Validates input text according to `target` parameter's button. Toggles output section elements to show or hide resulting text and CSS error class on input field's parent element. If valid, alerts success message to screen reader, clears input text and focus on copy button to easily copy output text to clipboard.
- `cryptography.init`: Attaches `cryptography.submit` to the buttons responsible for encrypt and decrypt.

### Method `input`
- `input.toggleSectionFocus`: Toggles CSS class for focus styles on input field parent element.
- `input.clearError`: Restores initial input field message and removes accessibility attribute and CSS error class from parent element.
- `input.set`: Attaches `input.toggleSectionFocus` and `input.clearError` methods to input field events.

<br>

### [🡨 previous](/docs/en/feature-translation.md)
2 changes: 1 addition & 1 deletion docs/en/feature-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ The initial language code value is detected through `navigator.language` and sav

<br>

### [🡨 previous](/docs/en/feature-theme.md)
### [🡨 previous](/docs/en/feature-theme.md)[next 🡪](/docs/en/feature-cryptography.md)
1 change: 1 addition & 0 deletions docs/en/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Index | Title
2 | [Features](/docs/en/features.md)
2.1 | [Features - Theme](/docs/en/feature-theme.md)
2.2 | [Features - Translation](/docs/en/feature-translation.md)
2.3 | [Features - Cryptography](/docs/en/feature-cryptography.md)

<br>

Expand Down
20 changes: 20 additions & 0 deletions docs/pt/feature-cryptography.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Decoder - 2. Funcionalidades
## 2.3. Criptografia
### cryptography.js
Criptografia substitui cada letra por seu termo correspondente e descriptografia substitui cada termo por sua letra correspondente. As entradas de letras e termos podem ser encontradas em [`cryptographyEntries.js`](/src/js/cryptographyEntries.js). Criptografia possui validações e alerta para informar texto de entrada inválido. Quando válido, o texto de entrada é limpo e o texto de saída é mostrado com opção de copiá-lo. Quando inválido, a saída é limpa e ocultada.

### Método `cryptography`
- `cryptography.data`: Retorna ambas chaves de criptografia e seu resultado de acordo com o botão `target` passado como parâmetro, que pode ser *criptografar* ou *descriptografar*. Reverte entradas se *descriptografar* for o alvo. Substitui o texto de entrada usando as chaves de criptografia como `regEx` do método `replace` para obter o texto de saída.
- `cryptography.validate`: Retorna `true` se o texto de entrada for válido ou `false` se inválido, de acordo com o botão do parâmetro `target`.
- `validations`: Submétodo de condições, cada uma retornando `true` ou uma mensagem de erro. Define a mensagem de erro e alerta-a para o leitor de tela ou restaura a mensagem inicial e remove o alerta.
- `cryptography.submit`: Valida o texto de entrada de acordo com o botão do parâmetro `target`. Alterna os elementos da seção de saída para mostrar ou ocultar o texto resultante e a classe de erro CSS no elemento pai do campo de entrada. Se válido, alerta a mensagem de sucesso para o leitor de tela, limpa o texto de entrada e foca o botão copiar para copiar facilmente o texto de saída para a área de transferência.
- `cryptography.init`: Anexa `cryptography.submit` aos botões responsáveis ​​por criptografar e descriptografar.

### Método `input`
- `input.toggleSectionFocus`: Alterna classe CSS para estilos de foco no elemento pai do campo de entrada.
- `input.clearError`: Restaura mensagem inicial do campo de entrada e remove atributo de acessibilidade e classe CSS de erro do elemento pai.
- `input.set`: Anexa os métodos `input.toggleSectionFocus` e `input.clearError` a eventos do campo de entrada.

<br>

### [🡨 anterior](/docs/pt/feature-translation.md)
2 changes: 1 addition & 1 deletion docs/pt/feature-translation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ O valor inicial do código do idioma é detectado através de `navigator.languag

<br>

### [🡨 anterior](/docs/pt/feature-theme.md)
### [🡨 anterior](/docs/pt/feature-theme.md)[próximo 🡪](/docs/pt/feature-cryptography.md)
1 change: 1 addition & 0 deletions docs/pt/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
2 | [Funcionalidades](/docs/pt/features.md)
2.1 | [Funcionalidades - Tema](/docs/pt/feature-theme.md)
2.2 | [Funcionalidades - Tradução](/docs/pt/feature-translation.md)
2.3 | [Funcionalidades - Criptografia](/docs/pt/feature-cryptography.md)

<br>

Expand Down

0 comments on commit a70e5b9

Please sign in to comment.