├── README.md └── src └── keyvault-encrypt-decrypt.http /README.md: -------------------------------------------------------------------------------- 1 | # AzureKeyVault-Encrypt-Decrypt-HttpFile 2 | Arquivo .http para testes de encriptação/decriptação com Azure Key Vault e utilizando uma App Registration do Microsoft Entra/Azure AD. 3 | 4 | Extensão utilizada do **Visual Studio Code** para execução do **arquivo .http**: 5 | 6 | [**REST Client - Artigo**](https://renatogroffe.medium.com/dicas-de-visual-studio-code-testando-apis-rest-com-instru%C3%A7%C3%B5es-curl-via-script-pt-15-9987ac414a23) -------------------------------------------------------------------------------- /src/keyvault-encrypt-decrypt.http: -------------------------------------------------------------------------------- 1 | # Documentacao: 2 | # https://learn.microsoft.com/en-us/rest/api/keyvault/keys/decrypt/decrypt?tabs=HTTP 3 | # https://learn.microsoft.com/en-us/rest/api/keyvault/keys/encrypt/encrypt?tabs=HTTP 4 | # Associada a role "Key Vault Crypto User" para a App Registration 5 | 6 | @tenant_id=00000000-0000-0000-0000-000000000000 7 | @client_id=00000000-0000-0000-0000-000000000000 8 | @client_secret=SECRET_APP_REGISTRATION 9 | @resource=https://vault.azure.net 10 | @url_Key=URL_CRYPTOGRAPHY_KEY_AZURE_KEY_VAULT 11 | 12 | # @name autenticar 13 | POST https://login.microsoft.com/{{tenant_id}}/oauth2/token 14 | Content-Type: application/x-www-form-urlencoded 15 | 16 | grant_type=client_credentials 17 | &client_id={{client_id}} 18 | &client_secret={{client_secret}} 19 | &resource={{resource}} 20 | 21 | ### 22 | 23 | @token = {{autenticar.response.body.$.access_token}} 24 | 25 | ### 26 | 27 | # @name encriptar 28 | POST {{url_Key}}/encrypt?api-version=7.4 29 | Authorization: Bearer {{token}} 30 | Content-Type: application/json 31 | 32 | { 33 | "alg": "RSA-OAEP", 34 | "value": "Q2FuYWxEb3ROZXQ=" 35 | } 36 | 37 | ### 38 | 39 | @valorEncriptado={{encriptar.response.body.$.value}} 40 | 41 | ### 42 | 43 | # @name decriptar 44 | POST {{url_Key}}/decrypt?api-version=7.4 45 | Authorization: Bearer {{token}} 46 | Content-Type: application/json 47 | 48 | { 49 | "alg": "RSA-OAEP", 50 | "value": "{{valorEncriptado}}" 51 | } --------------------------------------------------------------------------------