🤬
  • ■ ■ ■ ■ ■ ■
    Projects/7_ROT13_Cipher/.gitignore
     1 +/target/
     2 +!.mvn/wrapper/maven-wrapper.jar
     3 + 
     4 +### STS ###
     5 +.apt_generated
     6 +.classpath
     7 +.factorypath
     8 +.project
     9 +.settings
     10 +.springBeans
     11 +.sts4-cache
     12 + 
     13 +### IntelliJ IDEA ###
     14 +.idea
     15 +*.iws
     16 +*.iml
     17 +*.ipr
     18 +/out/
     19 + 
     20 +### NetBeans ###
     21 +/nbproject/private/
     22 +/build/
     23 +/nbbuild/
     24 +/dist/
     25 +/nbdist/
     26 +/.nb-gradle/
     27 + 
     28 +*.xml.versionsBackup
  • ■ ■ ■ ■ ■ ■
    Projects/7_ROT13_Cipher/README.md
     1 +<h1 align="center">ROT13 Cipher tool</h1>
     2 + 
     3 +## :information_source: technologies used
     4 + 
     5 +* Java
     6 + 
     7 +<h2 align="center"> Encrypt </h2>
     8 + 
     9 +![image](https://user-images.githubusercontent.com/32443720/161871552-8069d2bb-5401-47d3-8540-8ef7a8109c96.png)
     10 + 
     11 + 
     12 +<h2 align="center"> Decrypt </h2>
     13 + 
     14 +![image](https://user-images.githubusercontent.com/32443720/161871561-16ca9506-19e2-49c4-9b81-183ec77a917c.png)
     15 + 
     16 + 
     17 +```java
     18 +private void cipherDecipher(String message, int offset){
     19 + StringBuilder sb = new StringBuilder();
     20 + for (int i = 0; i < message.length(); i++) {
     21 + char c = message.charAt(i);
     22 + if (c >= 'a' && c <= 'm') c += offset;
     23 + else if (c >= 'A' && c <= 'M') c += offset;
     24 + else if (c >= 'n' && c <= 'z') c -= offset;
     25 + else if (c >= 'N' && c <= 'Z') c -= offset;
     26 + sb.append(c);
     27 + }
     28 + textAreaOutput.setText(sb.toString());
     29 +}
     30 +```
     31 + 
     32 +## :books: References
     33 + 
     34 +https://stackoverflow.com/questions/25537465/rot13-decode-in-java
     35 + 
     36 +https://en.wikipedia.org/wiki/ROT13
  • ■ ■ ■ ■ ■ ■
    Projects/7_ROT13_Cipher/src/Main.java
     1 +import javax.swing.*;
     2 +import javax.swing.border.EmptyBorder;
     3 +import javax.swing.event.DocumentEvent;
     4 +import javax.swing.event.DocumentListener;
     5 +import javax.swing.text.BadLocationException;
     6 + 
     7 +public class Main extends JFrame {
     8 + private final JTextArea textAreaOutput;
     9 + private final int offset = 13;
     10 + private String message = "";
     11 + 
     12 + public Main() {
     13 + JPanel contentPane = new JPanel();
     14 + setTitle("ROT13 Cipher tool");
     15 + setResizable(false);
     16 + setBounds(100, 100, 800, 600);
     17 + contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
     18 + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     19 + setContentPane(contentPane);
     20 + contentPane.setLayout(null);
     21 + 
     22 + //input
     23 + JLabel labelInput = new JLabel("Input:");
     24 + labelInput.setBounds(10, 0, 146, 29);
     25 + contentPane.add(labelInput);
     26 + 
     27 + JScrollPane scrollPaneInput = new JScrollPane();
     28 + scrollPaneInput.setEnabled(false);
     29 + scrollPaneInput.setBounds(10, 30, 780, 250);
     30 + 
     31 + JTextArea textAreaInput = new JTextArea();
     32 + textAreaInput.getDocument().addDocumentListener(new DocumentListener() {
     33 + @Override
     34 + public void insertUpdate(DocumentEvent documentEvent) {
     35 + try {
     36 + message = documentEvent.getDocument().getText(0, documentEvent.getDocument().getLength());
     37 + cipherDecipher(message,offset);
     38 + } catch (BadLocationException e) {
     39 + e.printStackTrace();
     40 + }
     41 + }
     42 + 
     43 + @Override
     44 + public void removeUpdate(DocumentEvent documentEvent) {
     45 + try {
     46 + message = documentEvent.getDocument().getText(0, documentEvent.getDocument().getLength());
     47 + cipherDecipher(message,offset);
     48 + } catch (BadLocationException e) {
     49 + e.printStackTrace();
     50 + }
     51 + 
     52 + }
     53 + 
     54 + @Override
     55 + public void changedUpdate(DocumentEvent documentEvent) {
     56 + try {
     57 + message = documentEvent.getDocument().getText(0, documentEvent.getDocument().getLength());
     58 + cipherDecipher(message,offset);
     59 + } catch (BadLocationException e) {
     60 + e.printStackTrace();
     61 + }
     62 + 
     63 + }
     64 + });
     65 + scrollPaneInput.setViewportView(textAreaInput);
     66 + contentPane.add(scrollPaneInput);
     67 + 
     68 + //output
     69 + JLabel labelOutput = new JLabel("Output:");
     70 + labelOutput.setBounds(10, 275, 146, 29);
     71 + 
     72 + JScrollPane scrollPaneOutput = new JScrollPane();
     73 + scrollPaneOutput.setEnabled(false);
     74 + scrollPaneOutput.setBounds(10, 300, 780, 250);
     75 + 
     76 + textAreaOutput = new JTextArea();
     77 + scrollPaneOutput.setViewportView(textAreaOutput);
     78 + 
     79 + contentPane.add(labelOutput);
     80 + contentPane.add(scrollPaneOutput);
     81 + scrollPaneOutput.setViewportView(textAreaOutput);
     82 + }
     83 + 
     84 + private void cipherDecipher(String message, int offset){
     85 + StringBuilder sb = new StringBuilder();
     86 + for (int i = 0; i < message.length(); i++) {
     87 + char c = message.charAt(i);
     88 + if (c >= 'a' && c <= 'm') c += offset;
     89 + else if (c >= 'A' && c <= 'M') c += offset;
     90 + else if (c >= 'n' && c <= 'z') c -= offset;
     91 + else if (c >= 'N' && c <= 'Z') c -= offset;
     92 + sb.append(c);
     93 + }
     94 + textAreaOutput.setText(sb.toString());
     95 + }
     96 + 
     97 + public static void main(String[] args){
     98 + Main main = new Main();
     99 + main.setVisible(true);
     100 + }
     101 +}
     102 + 
  • ■ ■ ■ ■
    README.md
    skipped 37 lines
    38 38  [4] | Server for file transfers | :heavy_check_mark:
    39 39  [5] | Caesar Cipher tool | :heavy_check_mark:
    40 40  [6] | TCP chat server -> The messages should be encoded with Caesar Cipher | :x:
    41  -[7] | ROT13 Cipher | :x:
     41 +[7] | ROT13 Cipher | :heavy_check_mark:
    42 42  [8] | UDP Chat server -> The messages should be encoded with ROT13 Cipher | :x:
    43 43  [9] | Remote command execution | :x:
    44 44  [10] | Recreate the Netcat tool | :x:
    skipped 123 lines
Please wait...
Page is in error, reload to recover