Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mookid8000/permitski
:necktie: Signature thing
https://github.com/mookid8000/permitski
license-checking sign-documents signer
Last synced: about 2 months ago
JSON representation
:necktie: Signature thing
- Host: GitHub
- URL: https://github.com/mookid8000/permitski
- Owner: mookid8000
- License: other
- Created: 2019-05-16T06:28:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-17T12:41:54.000Z (8 months ago)
- Last Synced: 2024-05-17T13:56:03.434Z (8 months ago)
- Topics: license-checking, sign-documents, signer
- Language: C#
- Size: 1.59 MB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Permitski
A simple .NET library for generating crypgraphically signed documents.
First you generate a key
```csharp
var key = DocumentSigner.GenerateKey();
```which you might want to hold on to, because it's your secret.
If you lose the key, you lose the ability to sign documents and validate signatures of signed documents, so you can probably imagine that it's pretty important.
With the key in hand, you can create a signer like this:
```csharp
using(var signer = new DocumentSigner(key))
{
// sign & validate stuff in here
}
```Since it's relying on unmanaged resources some place deep within the bowels of the .NET framework, you want to make sure that you dispose the signer properly.
Now, let's pretend we have some important data we want to pass around with a signature, so we can validate its authenticity later on. Here's the class that represents our important data:
```csharp
class ImportantData
{
public string Data { get; }public ImportantData(string data)
{
Data = data;
}
}
```Let's sign it, so we can give it to someone:
```csharp
var importantData = new ImportantData("hemmelig");var signed = signer.Sign(importantData);
Console.WriteLine(signed);
```which in this case yielded the following output:
```json
{
"Document": {
"Data": "hemmelig"
},
"Signature": "YHZxo95/CfP4P/ndfh+49m5kmjb2Zj8xkGrkvKVFbcw="
}
```Let's see if it's valid - if we store the JSON shown above in a string called `json`, we can check its validity like this:
```csharp
Console.WriteLine($"The document is valid: {signer.IsValid(json)}");
```
which on my machine yielded:
```
The document is valid: True
```Neat!