# SAF-T: Utils

[**CryptoSAF-T: SAF-T Utils**](https://github.com/assoft-portugal/CryptoSAF-T-SAF-T-Utils): é um ambiente escrito em JAVA que permite testar o método de encriptação do ficheiro SAF-T (PT) usando o algoritmo AES-128-CTR (FastSaftEncrypt), assim, como a canonização do ficheiro SAF-T (PT) original (FastHashCannon).

{% tabs %}
{% tab title="FastHashCannon" %}

### Execução

`pt.cryptosaft.demo.FastHashCannon [inputXml] [outputXml]`

| Argumento | Descrição                 | Valores            |
| --------- | ------------------------- | ------------------ |
| inputXml  | Ficheiro SAF-T de entrada | Ex: `saft.xml`     |
| outputXml | Ficheiro SAF-T canonizado | Ex: `saft_can.xml` |

### **JAR**

`java -jar jar/FastHashCannon.jar-jar-with-dependencies.jar src/main/resources/Exemplo_Facturacao.xml`
{% endtab %}

{% tab title="FastSaftEncrypt" %}

### Execução

`pt.cryptosaft.demo.FastSaftEncrypt [modo] [inputXml] [outputXml] [chave] [iv]`

| Argumento | Descrição                                | Valores                                                                                      |
| --------- | ---------------------------------------- | -------------------------------------------------------------------------------------------- |
| modo      | Modo de operação                         | <p><code>E</code> - Descaracterização (Encrypt);<br><code>D</code> - Reversão (Decrypt);</p> |
| inputXml  | Ficheiro SAF-T de entrada                | Ex: `saft.xml`                                                                               |
| outputXml | Ficheiro SAF-T de saída                  | Ex: `saft_desc.xml`                                                                          |
| chave     | Chave simétrica em formato Base64        | Ex: `8/K97v8vQqbD/ShX5yx+3g==`                                                               |
| iv        | Vetor de inicialização em formato Base64 | Ex: `+KSjwLJcoMXl7W+U1y5VtQ==`                                                               |

### **JAR**

`java -jar jar/FastSaftEncrypt.jar-jar-with-dependencies.jar E src/main/resources/Exemplo_Facturacao.xml /src/main/resources/CryptoSAFT-Exemplo_Facturacao.xml 8/K97v8vQqbD/ShX5yx+3g== +KSjwLJcoMXl7W+U1y5VtQ==`
{% endtab %}
{% endtabs %}


---

# 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://cryptosaft.assoft.org/ferramentas/cryptosaf-t-utils.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.
