> For the complete documentation index, see [llms.txt](https://ftcoders.first-tech.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ftcoders.first-tech.com/hop-api/docs/crypto.md).

# Crypto

## Data Encryption Module

> Returns encrypted data and IV (if applicable) (in retMultiValue), always in Hex format, in case of error, it returns details in the Error fields (retCode and RetDescription). Returns the following in retMultiValue:\
> &#x20; in retMultiValue:\<br>\<br> \<blockquote> retMultiValue\[0] = msgRespEncrypted\
> &#x20; -> Encrypted message (open)\<br> retMultiValue\[1] = ivResp - > IV for the\
> &#x20; next call to decrypt only in case of modeEncFlag 01, 02, 03, otherwise this\
> &#x20; field will be null\</blockquote>.<br>

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"tags":[{"name":"Crypto","description":"Operações de criptografia e descriptografia de dados"}],"servers":[{"url":"https://api-hext.first-tech.net","description":"Homologação (OKE)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Token JWT obtido via Auth0"}},"schemas":{"EncryptDataInput":{"allOf":[{"$ref":"#/components/schemas/CryptoInputBase"},{"type":"object","required":["p_ht_data"],"properties":{"p_ht_data":{"type":"string","description":"Dados a serem criptografados em formato H (Hex) ou T (Texto)"},"b_data":{"type":"string","nullable":true,"description":"Dados em formato binário (uso reservado)"}}}]},"CryptoInputBase":{"type":"object","required":["client_id","keyId","modeEncFlag","data_fmt"],"properties":{"client_id":{"type":"integer","format":"int64","minimum":1,"description":"Identificador do cliente"},"keyId":{"type":"string","description":"Alias/identificador da chave no banco de dados"},"modeEncFlag":{"type":"string","description":"Modo de operação da cifra:\n- `00`: ECB (padrão se null ou valor não listado)\n- `01`: CBC (requer IV)\n- `02`: CFB8 (requer IV)\n- `03`: CFB64 (requer IV)\n"},"ksn_desc":{"type":"string","nullable":true,"description":"Descritor KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"ksn":{"type":"string","nullable":true,"description":"KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"iv":{"type":"string","nullable":true,"description":"Vetor de inicialização em Hex — obrigatório nos modos 01, 02, 03"},"data_fmt":{"type":"string","enum":["H","T"],"description":"Formato dos dados de entrada:\n- `H`: Hexadecimal\n- `T`: Texto\n"}}},"ReturnMultiValue":{"type":"object","properties":{"retCode":{"type":"integer","description":"Código de retorno. 0 = sucesso, outros valores indicam erro"},"retValue":{"type":"string","description":"Valor de retorno simples (geralmente vazio em sucesso)"},"retMultiValue":{"type":"array","nullable":true,"items":{"type":"string","nullable":true},"description":"Array com os valores de retorno da operação"},"retValid":{"type":"boolean","description":"Indica se a operação foi bem-sucedida"},"retDescription":{"type":"string","description":"Descrição do resultado"}}},"ReturnError":{"type":"object","properties":{"retCode":{"type":"integer","description":"Código de erro:\n- `500`: Erro interno\n- `4097`: Formato inválido\n- `155`: Chave não encontrada no banco de dados\n"},"retValue":{"type":"string"},"retMultiValue":{"nullable":true},"retValid":{"type":"boolean"},"retDescription":{"type":"string","description":"Descrição do erro"}}}}},"paths":{"/v4/PayShieldCrypto/EncryptData":{"post":{"tags":["Crypto"],"summary":"Data Encryption Module","description":"Returns encrypted data and IV (if applicable) (in retMultiValue), always in Hex format, in case of error, it returns details in the Error fields (retCode and RetDescription). Returns the following in retMultiValue:\n  in retMultiValue:<br><br> <blockquote> retMultiValue[0] = msgRespEncrypted\n  -> Encrypted message (open)<br> retMultiValue[1] = ivResp - > IV for the\n  next call to decrypt only in case of modeEncFlag 01, 02, 03, otherwise this\n  field will be null</blockquote>.\n","operationId":"encryptData","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/EncryptDataInput"}}}},"responses":{"200":{"description":"Operação realizada com sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnMultiValue"}}}},"401":{"description":"Não autorizado — token Bearer ausente ou inválido"},"404":{"description":"Chave não encontrada no banco de dados","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnError"}}}},"500":{"description":"Erro interno do servidor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnError"}}}}}}}}}
```

## Data Decryption Module

> Returns decrypted data and IV (if applicable) (retMultiValue), always in Hex format, in case of error, it returns details in the Error fields (retCode and RetDescription).\
> Returns the following in retMultiValue:\<br> Returns the following\
> &#x20; in retMultiValue:\<br>\<br> \<blockquote> retMultiValue\[0] = msgRespDecrypted\
> &#x20; -> Decrypted message (open)\<br> retMultiValue\[1] = ivResp - > IV for the\
> &#x20; next call to encrypt only in case of modeEncFlag 01, 02, 03, otherwise this\
> &#x20; field will be null\</blockquote>.<br>

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"tags":[{"name":"Crypto","description":"Operações de criptografia e descriptografia de dados"}],"servers":[{"url":"https://api-hext.first-tech.net","description":"Homologação (OKE)"}],"security":[{"bearerAuth":[]}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"JWT","description":"Token JWT obtido via Auth0"}},"schemas":{"DecryptDataInput":{"allOf":[{"$ref":"#/components/schemas/CryptoInputBase"},{"type":"object","required":["p_h_data"],"properties":{"p_h_data":{"type":"string","description":"Dados criptografados a serem descriptografados em formato Hex"}}}]},"CryptoInputBase":{"type":"object","required":["client_id","keyId","modeEncFlag","data_fmt"],"properties":{"client_id":{"type":"integer","format":"int64","minimum":1,"description":"Identificador do cliente"},"keyId":{"type":"string","description":"Alias/identificador da chave no banco de dados"},"modeEncFlag":{"type":"string","description":"Modo de operação da cifra:\n- `00`: ECB (padrão se null ou valor não listado)\n- `01`: CBC (requer IV)\n- `02`: CFB8 (requer IV)\n- `03`: CFB64 (requer IV)\n"},"ksn_desc":{"type":"string","nullable":true,"description":"Descritor KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"ksn":{"type":"string","nullable":true,"description":"KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"iv":{"type":"string","nullable":true,"description":"Vetor de inicialização em Hex — obrigatório nos modos 01, 02, 03"},"data_fmt":{"type":"string","enum":["H","T"],"description":"Formato dos dados de entrada:\n- `H`: Hexadecimal\n- `T`: Texto\n"}}},"ReturnMultiValue":{"type":"object","properties":{"retCode":{"type":"integer","description":"Código de retorno. 0 = sucesso, outros valores indicam erro"},"retValue":{"type":"string","description":"Valor de retorno simples (geralmente vazio em sucesso)"},"retMultiValue":{"type":"array","nullable":true,"items":{"type":"string","nullable":true},"description":"Array com os valores de retorno da operação"},"retValid":{"type":"boolean","description":"Indica se a operação foi bem-sucedida"},"retDescription":{"type":"string","description":"Descrição do resultado"}}},"ReturnError":{"type":"object","properties":{"retCode":{"type":"integer","description":"Código de erro:\n- `500`: Erro interno\n- `4097`: Formato inválido\n- `155`: Chave não encontrada no banco de dados\n"},"retValue":{"type":"string"},"retMultiValue":{"nullable":true},"retValid":{"type":"boolean"},"retDescription":{"type":"string","description":"Descrição do erro"}}}}},"paths":{"/v4/PayShieldCrypto/DecryptData":{"post":{"tags":["Crypto"],"summary":"Data Decryption Module","description":"Returns decrypted data and IV (if applicable) (retMultiValue), always in Hex format, in case of error, it returns details in the Error fields (retCode and RetDescription).\nReturns the following in retMultiValue:<br> Returns the following\n  in retMultiValue:<br><br> <blockquote> retMultiValue[0] = msgRespDecrypted\n  -> Decrypted message (open)<br> retMultiValue[1] = ivResp - > IV for the\n  next call to encrypt only in case of modeEncFlag 01, 02, 03, otherwise this\n  field will be null</blockquote>.\n","operationId":"decryptData","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/DecryptDataInput"}}}},"responses":{"200":{"description":"Operação realizada com sucesso","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnMultiValue"}}}},"400":{"description":"Formato de data_fmt inválido — use 'H' (Hexadecimal) ou 'T' (Texto)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnError"}}}},"401":{"description":"Não autorizado — token Bearer ausente ou inválido"},"404":{"description":"Chave não encontrada no banco de dados","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnError"}}}},"500":{"description":"Erro interno do servidor","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ReturnError"}}}}}}}}}
```

## The CryptoInputBase object

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"components":{"schemas":{"CryptoInputBase":{"type":"object","required":["client_id","keyId","modeEncFlag","data_fmt"],"properties":{"client_id":{"type":"integer","format":"int64","minimum":1,"description":"Identificador do cliente"},"keyId":{"type":"string","description":"Alias/identificador da chave no banco de dados"},"modeEncFlag":{"type":"string","description":"Modo de operação da cifra:\n- `00`: ECB (padrão se null ou valor não listado)\n- `01`: CBC (requer IV)\n- `02`: CFB8 (requer IV)\n- `03`: CFB64 (requer IV)\n"},"ksn_desc":{"type":"string","nullable":true,"description":"Descritor KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"ksn":{"type":"string","nullable":true,"description":"KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"iv":{"type":"string","nullable":true,"description":"Vetor de inicialização em Hex — obrigatório nos modos 01, 02, 03"},"data_fmt":{"type":"string","enum":["H","T"],"description":"Formato dos dados de entrada:\n- `H`: Hexadecimal\n- `T`: Texto\n"}}}}}}
```

## The EncryptDataInput object

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"components":{"schemas":{"EncryptDataInput":{"allOf":[{"$ref":"#/components/schemas/CryptoInputBase"},{"type":"object","required":["p_ht_data"],"properties":{"p_ht_data":{"type":"string","description":"Dados a serem criptografados em formato H (Hex) ou T (Texto)"},"b_data":{"type":"string","nullable":true,"description":"Dados em formato binário (uso reservado)"}}}]},"CryptoInputBase":{"type":"object","required":["client_id","keyId","modeEncFlag","data_fmt"],"properties":{"client_id":{"type":"integer","format":"int64","minimum":1,"description":"Identificador do cliente"},"keyId":{"type":"string","description":"Alias/identificador da chave no banco de dados"},"modeEncFlag":{"type":"string","description":"Modo de operação da cifra:\n- `00`: ECB (padrão se null ou valor não listado)\n- `01`: CBC (requer IV)\n- `02`: CFB8 (requer IV)\n- `03`: CFB64 (requer IV)\n"},"ksn_desc":{"type":"string","nullable":true,"description":"Descritor KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"ksn":{"type":"string","nullable":true,"description":"KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"iv":{"type":"string","nullable":true,"description":"Vetor de inicialização em Hex — obrigatório nos modos 01, 02, 03"},"data_fmt":{"type":"string","enum":["H","T"],"description":"Formato dos dados de entrada:\n- `H`: Hexadecimal\n- `T`: Texto\n"}}}}}}
```

## The DecryptDataInput object

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"components":{"schemas":{"DecryptDataInput":{"allOf":[{"$ref":"#/components/schemas/CryptoInputBase"},{"type":"object","required":["p_h_data"],"properties":{"p_h_data":{"type":"string","description":"Dados criptografados a serem descriptografados em formato Hex"}}}]},"CryptoInputBase":{"type":"object","required":["client_id","keyId","modeEncFlag","data_fmt"],"properties":{"client_id":{"type":"integer","format":"int64","minimum":1,"description":"Identificador do cliente"},"keyId":{"type":"string","description":"Alias/identificador da chave no banco de dados"},"modeEncFlag":{"type":"string","description":"Modo de operação da cifra:\n- `00`: ECB (padrão se null ou valor não listado)\n- `01`: CBC (requer IV)\n- `02`: CFB8 (requer IV)\n- `03`: CFB64 (requer IV)\n"},"ksn_desc":{"type":"string","nullable":true,"description":"Descritor KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"ksn":{"type":"string","nullable":true,"description":"KSN — necessário apenas se o keyId for do tipo BDK (DUKPT)"},"iv":{"type":"string","nullable":true,"description":"Vetor de inicialização em Hex — obrigatório nos modos 01, 02, 03"},"data_fmt":{"type":"string","enum":["H","T"],"description":"Formato dos dados de entrada:\n- `H`: Hexadecimal\n- `T`: Texto\n"}}}}}}
```

## The ReturnMultiValue object

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"components":{"schemas":{"ReturnMultiValue":{"type":"object","properties":{"retCode":{"type":"integer","description":"Código de retorno. 0 = sucesso, outros valores indicam erro"},"retValue":{"type":"string","description":"Valor de retorno simples (geralmente vazio em sucesso)"},"retMultiValue":{"type":"array","nullable":true,"items":{"type":"string","nullable":true},"description":"Array com os valores de retorno da operação"},"retValid":{"type":"boolean","description":"Indica se a operação foi bem-sucedida"},"retDescription":{"type":"string","description":"Descrição do resultado"}}}}}}
```

## The ReturnError object

```json
{"openapi":"3.0.3","info":{"title":"PayShield Crypto API","version":"4.1.32"},"components":{"schemas":{"ReturnError":{"type":"object","properties":{"retCode":{"type":"integer","description":"Código de erro:\n- `500`: Erro interno\n- `4097`: Formato inválido\n- `155`: Chave não encontrada no banco de dados\n"},"retValue":{"type":"string"},"retMultiValue":{"nullable":true},"retValid":{"type":"boolean"},"retDescription":{"type":"string","description":"Descrição do erro"}}}}}}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://ftcoders.first-tech.com/hop-api/docs/crypto.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
