{"id":30663416,"url":"https://github.com/simpsonresearch/rsa-azure-key-vault-encryption","last_synced_at":"2026-05-03T15:32:06.543Z","repository":{"id":278299216,"uuid":"935164932","full_name":"simpsonresearch/rsa-azure-key-vault-encryption","owner":"simpsonresearch","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-19T13:10:14.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-02-12T09:54:30.074Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simpsonresearch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-19T02:23:42.000Z","updated_at":"2025-02-19T13:10:18.000Z","dependencies_parsed_at":"2025-02-19T03:35:57.597Z","dependency_job_id":"c93d4fdc-253e-4a58-9ff3-bed7a0fd79a5","html_url":"https://github.com/simpsonresearch/rsa-azure-key-vault-encryption","commit_stats":null,"previous_names":["simpson-computer-technologies-research/rsa-azure-key-vault-encryption","simpsonresearch/rsa-azure-key-vault-encryption"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/simpsonresearch/rsa-azure-key-vault-encryption","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Frsa-azure-key-vault-encryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Frsa-azure-key-vault-encryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Frsa-azure-key-vault-encryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Frsa-azure-key-vault-encryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simpsonresearch","download_url":"https://codeload.github.com/simpsonresearch/rsa-azure-key-vault-encryption/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simpsonresearch%2Frsa-azure-key-vault-encryption/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32574971,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-03T06:36:36.687Z","status":"ssl_error","status_checked_at":"2026-05-03T06:36:09.306Z","response_time":103,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-31T17:11:04.037Z","updated_at":"2026-05-03T15:32:06.514Z","avatar_url":"https://github.com/simpsonresearch.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# RSA Azure Key-Vault Encryption\n\nEnterprise-level encryption\n\n```ts\n//\n//\n// FRONTEND\n//\n//\n\nimport forge from \"node-forge\";\nimport axios from \"axios\";\n\n/**\n * Get public key from Azure Key Vault\n * \n * @param azureAccessToken Azure access token\n * \n * @returns Public key\n * \n * @example\n * const publicKey = await getPublicKey({ azureAccessToken });\n */\nexport const getPublicKey = async ({ azureAccessToken }: { azureAccessToken: string }) =\u003e {\n    const url = \"https://\u003cYOUR_KEYVAULT_NAME\u003e.vault.azure.net/keys/MyRSAKey?api-version=7.3\";\n\n    const res = await axios.get(url, {\n        headers: {\n            Authorization: `Bearer ${azureAccessToken}`,\n        }\n    });\n\n    const json = await res.json();\n\n    return json.key.n;\n}\n\n/**\n * Encrypt data with a public key (RSA)\n * \n * @param data Data to encrypt\n * @param publicKey Public key to encrypt with\n * @param expiresAt Expiration date in milliseconds\n * \n * @returns Encrypted data\n * \n * @example\n * const publicKey = await getPublicKey({ azureAccessToken });\n * const encrypted = await encrypt({ data: \"Hello, World!\", publicKey, expiresAt: Date.now() + 3600 * 1000 }); // Expires in 1 hour\n */\nexport const encrypt = async ({ data, publicKey, expiresAt }: Readonly\u003c{ data: string | undefined; publicKey: string; expiresAt?: number }\u003e) =\u003e {\n    const _toEncrypt = expiresAt !== undefined ? JSON.stringify({ data, expiresAt }) : data;\n\n    const _publicKey = forge.pki.publicKeyFromPem(publicKey);\n\n    const encrypted = _publicKey.encrypt(_toEncrypt, \"RSA-OAEP\");\n\n    return forge.util.encode64(encrypted);\n}\n\n//\n//\n// BACKEND\n//\n//\n\n/**\n * Decrypt data with a private key (RSA)\n * \n * @param data Data to decrypt\n * @param privateKey Private key to decrypt with\n * \n * @returns Decrypted data\n * \n * @example\n * const decrypted = await decrypt({ data: encrypted, azureAccessToken });\n */\nexport const decrypt = async ({ data, azureAccessToken }: Readonly\u003c{ data: string | undefined; azureAccessToken: string; }\u003e) =\u003e {\n    const url = \"https://\u003cYOUR_KEYVAULT_NAME\u003e.vault.azure.net/decrypt?api-version=7.3\";\n\n    const res = await axios.post(url, {\n        alg: \"RSA-OAEP\",\n        value: data,\n    }, {\n        headers: {\n            Authorization: `Bearer ${azureAccessToken}`,\n            \"Content-Type\": \"application/json\",\n        }\n    });\n\n    const json = await res.json();\n\n    return forge.util.decode64(json.value);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpsonresearch%2Frsa-azure-key-vault-encryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimpsonresearch%2Frsa-azure-key-vault-encryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimpsonresearch%2Frsa-azure-key-vault-encryption/lists"}