# 5. Perform Cryptography using AI

## 1. Perform Cryptographic Techniques using ShellGPT <a href="#task-1-perform-cryptographic-techniques-using-shellgpt" id="task-1-perform-cryptographic-techniques-using-shellgpt"></a>

ShellGPT augments cryptography through innovative techniques. It leverages shell commands to encrypt data, execute cryptographic operations, and manage key distribution securely. ShellGPT integrates with existing shell environments, enhancing encryption efficiency and reliability. Its adaptability and automation streamline cryptographic processes, fortifying data protection in diverse computing environments.

> The commands generated by ShellGPT may vary depending on the prompt used and the tools available on the machine. Due to these variables, the output generated by ShellGPT might differ from what is shown in the screenshots. These differences arise from the dynamic nature of the AI's processing and the diverse environments in which it operates. As a result, you may observe differences in command syntax, execution, and results while performing this lab task.

{% file src="/files/kyKy7JBGxav22LZx9zWd" %}
Follow the tutorial to integrate AI into shell
{% endfile %}

After incorporating the ShellGPT API in Parrot Security machine, run

```
sgpt --shell "Calculate MD5 hash of text 'My Account number is 0234569198'"
```

<figure><img src="/files/QU1kBd5LbDBYR9Yy458W" alt=""><figcaption></figcaption></figure>

Now, we will perform multi-layer hashing using ShellGPT to do so, run

```
sgpt --shell "Calculate MD5 hash of text 'My Account number is 0234569198' and calculate the SHA1 hash value of the MD5 value"
```

<figure><img src="/files/FXdnClALquBX6CXWBntI" alt=""><figcaption></figcaption></figure>

We will now calculate hash of a file using ShellGPT, to do so, run

```
sgpt --chat hash --shell "Calculate CRC32 hash of the file passwords.txt located at /home/attacker"
```

To perform basic encryption using ShellGPT run

```
sgpt --shell "Encrypt 'Hello World' text using base64 algorithm and save the result to Output.txt file"
```

<figure><img src="/files/CyPuIOk9gCdjDBv9iZlP" alt=""><figcaption></figcaption></figure>

Now we will decrypt the encrypted data using ShellGPT to do so, run

```
sgpt --shell "Decrypt the contents of encrypted Output.txt file located at /home/attacker using base64 algorithm"
```

{% embed url="<https://www.udemy.com/course/ethical-hacker-practical/?referralCode=289CF01CF51246BCAD6C>" %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ceh-practical.cavementech.com/module-20.-cryptography/5.-perform-cryptography-using-ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
