{"id":19555414,"url":"https://github.com/peter-gergely-horvath/windpapi4j","last_synced_at":"2025-10-07T15:45:55.746Z","repository":{"id":43005632,"uuid":"53668604","full_name":"peter-gergely-horvath/windpapi4j","owner":"peter-gergely-horvath","description":"Windows DPAPI JNA Wrapper","archived":false,"fork":false,"pushed_at":"2025-04-06T12:06:43.000Z","size":93,"stargazers_count":24,"open_issues_count":0,"forks_count":8,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-09T18:19:41.887Z","etag":null,"topics":["decryption","dpapi","encryption","java","jna","microsoft","windows-dpapi"],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peter-gergely-horvath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2016-03-11T13:24:34.000Z","updated_at":"2025-04-06T11:54:12.000Z","dependencies_parsed_at":"2024-11-11T04:34:06.438Z","dependency_job_id":"a31e5472-5241-4290-a82b-29a5d29ecc9a","html_url":"https://github.com/peter-gergely-horvath/windpapi4j","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-gergely-horvath%2Fwindpapi4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-gergely-horvath%2Fwindpapi4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-gergely-horvath%2Fwindpapi4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peter-gergely-horvath%2Fwindpapi4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peter-gergely-horvath","download_url":"https://codeload.github.com/peter-gergely-horvath/windpapi4j/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248085325,"owners_count":21045139,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["decryption","dpapi","encryption","java","jna","microsoft","windows-dpapi"],"created_at":"2024-11-11T04:33:52.702Z","updated_at":"2025-10-07T15:45:50.686Z","avatar_url":"https://github.com/peter-gergely-horvath.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# WinDPAPI4J: A Windows DPAPI Wrapper for Java\n\n## Introduction\n\nStarting from Microsoft(R) Windows(R) 2000, Windows operating systems provide \na built-in cryptographic feature called [\"Windows Data Protection API\" (DPAPI)](https://msdn.microsoft.com/en-us/library/ms995355.aspx), \nwhich allows any application to securely encrypt confidential user data using \nthe user's credentials in a way that it can only be decrypted by the same user.\n\nThis Java library exposes Windows Data Protection encryption and decryption\nfeatures as an easy to use Java API. Behind the scenes, [JNA (Java Native\nAccess)](https://github.com/java-native-access/jna/blob/master/www/GettingStarted.md)\nlibrary is used to invoke the native  Windows CryptoAPI\n`CryptProtectData` and `CryptUnprotectData` functions. \n\n**Note**:\n * Since this library exposes a Windows feature, it will only work, when called from a Java application running on Windows\n * Only an essential subset of Windows Data Protection API (DPAPI) is supported  by this library: advanced cases involving showing prompts to the user etc. \nare not implemented.\n\n###\n\nThe JavaDoc is part of the Maven Central installation and can be viewed online via [javadoc.io](http://javadoc.io/doc/com.github.peter-gergely-horvath/windpapi4j/1.0)\n## Passing special flags to Windows DPAPI\n\nAs described in _Microsoft Development Network Documentation on Cryptography\nFunctions_, both [CryptProtectData](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380882(v=vs.85).aspx) and\n[CryptUnprotectData](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380882(v=vs.85).aspx) \nfunctions accept optional flag values, which control their behaviour. \n\nThese optional flag values are defined in `WinDPAPI.CryptProtectFlag` as enum \nconstants and can be passed to the static factory method \n`WinDPAPI#newInstance(CryptProtectFlag...)`\nafter which the `WinDPAPI` instance returned will pass them to the target native \nWindows DPAPI method.\n\n## Mapping of methods\n\n**Methods for encryption**\n\n| WinDPAPI library methods                                 | Windows CryptoAPI method    |\n| -------------------------------------------------------- | --------------------------- |\n| `WinDPAPI#protectData(byte[])`                           | `CryptProtectData`          |\n| `WinDPAPI#protectData(byte[], byte[])`                   | `CryptProtectData`          |\n| `WinDPAPI#protectData(byte[], byte[], java.lang.String)` | `CryptProtectData`          |\n\n\n**Methods for decryption**\n\n| WinDPAPI library methods                                 | Windows CryptoAPI method    |\n| -------------------------------------------------------- | --------------------------- |\n| `WinDPAPI#unprotectData(byte[])`                         | `CryptUnprotectData`        |\n| `WinDPAPI#unprotectData(byte[], byte[])`                 | `CryptUnprotectData`        |\n\n\n## Sample Code\n\n```\npackage sample;\n  \nimport com.github.windpapi4j.WinDPAPI;\nimport com.github.windpapi4j.WinDPAPI.CryptProtectFlag;\n\npublic class Sample {\n\n    public static void main(String[] args) throws Exception {\n\n        if(WinDPAPI.isPlatformSupported()) {\n            WinDPAPI winDPAPI = WinDPAPI.newInstance(CryptProtectFlag.CRYPTPROTECT_UI_FORBIDDEN);\n\n            String message = \"Hello World!\";\n            String charsetName = \"UTF-8\";\n\n            byte[] clearTextBytes = message.getBytes(charsetName);\n\n            byte[] cipherTextBytes = winDPAPI.protectData(clearTextBytes);\n\n            byte[] decryptedBytes = winDPAPI.unprotectData(cipherTextBytes);\n\n            String decryptedMessage = new String(decryptedBytes, charsetName);\n\n            if(! message.equals(decryptedMessage) ) {\n                // should not happen\n                throw new IllegalStateException(message + \" != \" + decryptedMessage); \n            }\n\n            System.out.println(decryptedMessage);\n\n        } else {\n            System.err.println(\"ERROR: platform not supported\");\n        }\n    }\n}\n```\n\n## Availability\n\nThis library has been made available in [Maven Central Repository](https://central.sonatype.com/artifact/com.github.peter-gergely-horvath/windpapi4j/2.2.0).  \n\n## Version overview\n\n| Version  | Java version | Description                                                                                                |\n| ---------|--------------|------------------------------------------------------------------------------------------------------------|\n| 2.2.0    | 11           | Support added for GraalVM native image                                                                     |\n| 2.1.0    | 11           | Support added for Java modules                                                                             |\n| 2.0.0    | 8            | Rewrite, based on recent JNA platform; upgrade to modern JNA library versions, last modern Java 8 version. |\n| 1.1.0    | 8            | Upgrade to a more modern JNA library version, Obsolete, users are advised to upgrade to 2.2 version.       |\n| 1.0      | 8            | Initial public version based on the JNA platform. Obsolete, users are advised to upgrade to 2.2 version.   |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-gergely-horvath%2Fwindpapi4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeter-gergely-horvath%2Fwindpapi4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeter-gergely-horvath%2Fwindpapi4j/lists"}