|
1 | 1 | # Easy Sign |
2 | 2 |
|
3 | | -Simple C# Library for signing and verifying files. |
| 3 | +Easy Sign is a simple C# library for signing and verifying files. It supports multiple .NET targets, including .NET Standard 2.1, .NET 6, and .NET 8. |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Sign files with X.509 certificates. |
| 8 | +- Verify file integrity and signatures. |
| 9 | +- Store files within the bundle. |
| 10 | +- Support for concurrent operations. |
| 11 | + |
| 12 | +## Installation |
| 13 | + |
| 14 | +To install Easy Sign, run the following command: |
| 15 | + |
| 16 | + |
| 17 | +``` |
| 18 | +dotnet add package SAPTeam.EasySign |
| 19 | +
|
| 20 | +``` |
| 21 | + |
| 22 | +## Usage |
| 23 | + |
| 24 | +### Creating a Bundle |
| 25 | + |
| 26 | + |
| 27 | +``` |
| 28 | +using SAPTeam.EasySign; |
| 29 | +
|
| 30 | +// Initialize a new bundle |
| 31 | +var bundle = new Bundle("path/to/dir"); |
| 32 | +
|
| 33 | +// Add files to the bundle |
| 34 | +bundle.AddEntry("path/to/dir/file1.txt"); |
| 35 | +bundle.AddEntry("path/to/dir/file2.txt"); |
| 36 | +
|
| 37 | +// Sign the bundle |
| 38 | +var certificate = new X509Certificate2("path/to/certificate.pfx", "password"); |
| 39 | +var privateKey = certificate.GetRSAPrivateKey(); |
| 40 | +bundle.Sign(certificate, privateKey); |
| 41 | +
|
| 42 | +// Save the bundle |
| 43 | +bundle.Update(); |
| 44 | +
|
| 45 | +``` |
| 46 | + |
| 47 | +### Loading and Verifying a Bundle |
| 48 | + |
| 49 | + |
| 50 | +``` |
| 51 | +using SAPTeam.EasySign; |
| 52 | +
|
| 53 | +// Load an existing bundle |
| 54 | +var bundle = new Bundle("path/to/dir"); |
| 55 | +bundle.LoadFromFile(); |
| 56 | +
|
| 57 | +// Get certificate hash |
| 58 | +string certificateHash = bundle.Signatures.Entries.First().Key; |
| 59 | +
|
| 60 | +// Verify certificate |
| 61 | +bool isCertificateValid = bundle.VerifyCertificate(certificateHash); |
| 62 | +
|
| 63 | +// Verify signature |
| 64 | +bool isSignatureValid = bundle.VerifySignature(certificateHash); |
| 65 | +
|
| 66 | +// Verify files integrity |
| 67 | +bool isFileValid = bundle.VerifyFileIntegrity("file1.txt"); |
| 68 | +bool isFile2Valid = bundle.VerifyFileIntegrity("file2.txt"); |
| 69 | +
|
| 70 | +``` |
| 71 | + |
| 72 | +## Command Line Interface |
| 73 | + |
| 74 | +Easy Sign also provides a command line interface (CLI) for signing and verifying files. To install the CLI tool, use the following command: |
| 75 | + |
| 76 | + |
| 77 | +``` |
| 78 | +dotnet tool install -g SAPTeam.EasySign.Tool |
| 79 | +
|
| 80 | +``` |
| 81 | + |
| 82 | +For more informations, see the [CLI Readme](https://github.com/SAPTeamDEV/EasySign/blob/master/src/EasySign.Cli/README.md). |
| 83 | + |
4 | 84 |
|
5 | 85 | ## License |
6 | 86 |
|
7 | | -This project is licensed under the MIT License. |
| 87 | +This project is licensed under the MIT License. |
0 commit comments