{"id":19992785,"url":"https://github.com/stanac/EasyCrypto","last_synced_at":"2025-05-04T12:30:25.590Z","repository":{"id":65365312,"uuid":"62445074","full_name":"stanac/EasyCrypto","owner":"stanac","description":"Easily encrypt/decrypt data and generate/hash/validate passwords ","archived":false,"fork":false,"pushed_at":"2024-03-19T17:11:50.000Z","size":4025,"stargazers_count":20,"open_issues_count":0,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T12:34:40.911Z","etag":null,"topics":["cryptography","decryption","encryption","password-hasher","passwordgenerator","random"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stanac.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-02T10:05:53.000Z","updated_at":"2024-12-02T21:51:57.000Z","dependencies_parsed_at":"2023-01-22T12:30:09.564Z","dependency_job_id":null,"html_url":"https://github.com/stanac/EasyCrypto","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanac%2FEasyCrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanac%2FEasyCrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanac%2FEasyCrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stanac%2FEasyCrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stanac","download_url":"https://codeload.github.com/stanac/EasyCrypto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252333945,"owners_count":21731300,"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":["cryptography","decryption","encryption","password-hasher","passwordgenerator","random"],"created_at":"2024-11-13T04:52:19.148Z","updated_at":"2025-05-04T12:30:24.197Z","avatar_url":"https://github.com/stanac.png","language":"C#","funding_links":[],"categories":["C\\#"],"sub_categories":[],"readme":"# EasyCrypto\n\n [![.NET Core](https://github.com/stanac/EasyCrypto/workflows/.NET%20Core/badge.svg)](https://github.com/stanac/EasyCrypto/actions?query=workflow%3A%22.NET+Core%22)\n [![Coverage Status](https://img.shields.io/coveralls/stanac/EasyCrypto/master.svg?maxAge=900)](https://coveralls.io/github/stanac/EasyCrypto?\u0026branch=master)\n [![NuGet](https://img.shields.io/nuget/v/EasyCrypto.svg)](https://www.nuget.org/packages/EasyCrypto/)\n [![downloads](https://img.shields.io/nuget/dt/EasyCrypto.svg?style=flat)](https://www.nuget.org/packages/EasyCrypto/)\n [![license](https://img.shields.io/github/license/stanac/EasyCrypto.svg)](https://github.com/stanac/EasyCrypto/blob/master/LICENSE)\n\nPrimary goal of this library is to enable users with little or no cryptography knowledge to encrypt and decrypt data in an easy and\nsafe manner as well work with passwords and random values.\n\nEasyCrypto is .NET 6, 7, 8+ library that helps with\n- Encryption and decryption of streams, byte arrays, strings and files\n- Password generating, hashing and validating\n- Generating crypto secure random bytes, integers and doubles\n- Generating crypto secure random string tokens and string identifiers\n\nFor .NETStandard 1.6 implementation use version 5.0.\n\nImplementation details:\n- For symmetric encryption AES265 is used, IVs are 128 bits large and every \nresult of the encryption is embedded with [KCV](https://en.wikipedia.org/wiki/Key_checksum_value) (just first three bytes)\nand [MAC](https://en.wikipedia.org/wiki/Message_authentication_code). MAC is calculated using HMACSHA384.\n- CryptoRandom and PasswordGenerator is using [RNGCryptoServiceProvider](https://msdn.microsoft.com/en-us/library/system.security.cryptography.rngcryptoserviceprovider.aspx)\n- Hashing of password is done with [Rfc2898DeriveBytes](msdn.microsoft.com/en-us/library/system.security.cryptography.rfc2898derivebytes.aspx)\nwith default hash and salt size of 256 bits and 25K iterations (by default).\n- Asymmetric (public key) encryption is using RSA with 2048 bits keys (by default).\n\n---\n\nVersion 5.0 is the last release which supports old .NET Framework 4.8 and will receive only\ncritical fixes.\nStarting from version 6 EasyCrypto will be built using officially supported releases of .NET (at the moment .NET 6 and .NET 7).\n\n---\n\nFor changes see [history](https://github.com/stanac/EasyCrypto/blob/master/HISTORY.md).\n\n## Install from nuget\n\n[nuget.org link](https://www.nuget.org/packages/EasyCrypto/)\n\n```\nInstall-Package EasyCrypto\n```\n\n## Docs\n\nTable of contents:\n- [EasyCrypto](#easycrypto)\n  - [Install from nuget](#install-from-nuget)\n  - [Docs](#docs)\n    - [Static class AesEncryption](#static-class-aesencryption)\n    - [Static class AesFileEncryption](#static-class-aesfileencryption)\n    - [Static class AesEncryptionAdditionalData](#static-class-aesencryptionadditionaldata)\n    - [Class CryptoRandom : IDisposable](#class-cryptorandom--idisposable)\n    - [Class ThreadSafeRandom](#class-threadsaferandom)\n    - [Class PasswordGenerator : IDisposable](#class-passwordgenerator--idisposable)\n    - [PasswordHasherAndValidator](#passwordhasherandvalidator)\n    - [Class PasswordHasher](#class-passwordhasher)\n    - [Class TokenGenerator](#class-tokengenerator)\n    - [Class IdGenerator](#class-idgenerator)\n    - [Static Class RsaEncryption](#static-class-rsaencryption)\n    - [Class QuickEncryption](#class-quickencryption)\n---\n\n### Static class AesEncryption\n\nAesEncryption class can work with streams, byte arrays and strings. \n\nAvailable methods:\n\n```csharp\nstatic void Encrypt(Stream dataToEncrypt, byte[] key, byte[] iv, Stream destination)\nstatic void Decrypt(Stream dataToDecrypt, byte[] key, byte[] iv, Stream destination)\n\nstatic byte[] Decrypt(byte[] dataToDecrypt, byte[] key, byte[] iv) \nstatic byte[] Encrypt(byte[] dataToEncrypt, byte[] key, byte[] iv)\n\n\n// following methods are generating random IV and embedding it into the encrypted data\n// so encrypted data can be decrypted with just the key\n\nstatic void EncryptAndEmbedIv(Stream dataToEncrypt, byte[] key, Stream destination)\nstatic void DecryptWithEmbeddedIv(Stream dataToDecrypt, byte[] key, Stream destination)\n\nstatic byte[] EncryptAndEmbedIv(byte[] dataToEncrypt, byte[] key)\nstatic byte[] DecryptWithEmbeddedIv(byte[] dataToDecrypt, byte[] key) \n\n\n// following methods are generating random salt and random IV\n// calculating hash from the password\n// then generated salt and hash are embeded into the encrypted data\n// so data can be decrypted using just the password\n\nstatic void EncryptWithPassword(Stream dataToEncrypt, string password, Stream destination)\nstatic void DecryptWithPassword(Stream dataToDecrypt, string password, Stream destination)\n\nstatic byte[] EncryptWithPassword(byte[] dataToEncrypt, string password)\nstatic byte[] DecryptWithPassword(byte[] dataToDecrypt, string password)\n\nstatic string EncryptWithPassword(string dataToEncrypt, string password)\nstatic string DecryptWithPassword(string dataToDecrypt, string password)\n\n\n// validation methods (from v1.1.0, used to verify key/password and data integrity):\n\nstatic ValidationResult ValidateEncryptedData(byte[] encryptedData, byte[] key, byte[] iv)\nstatic ValidationResult ValidateEncryptedData(Stream encryptedData, byte[] key, byte[] iv)\n\nstatic ValidationResult ValidateEncryptedDataWithEmbeddedIv(byte[] encryptedData, byte[] key)\nstatic ValidationResult ValidateEncryptedDataWithEmbeddedIv(Stream encryptedData, byte[] key)\n\nstatic ValidationResult ValidateEncryptedDataWithPassword(string encryptedData, string password)\nstatic ValidationResult ValidateEncryptedDataWithPassword(byte[] encryptedData, string password)\nstatic ValidationResult ValidateEncryptedDataWithPassword(Stream encryptedData, string password)\n```\n---\n\n### Static class AesFileEncryption\n\nFrom v3.2 we have API for file encryption in order to avoid out of memory exceptions\n\n```csharp\n// methods for encryption of files\nvoid Encrypt(string sourceFilePath, string destinationFilePath, byte[] key, byte[] iv, bool overwriteExistingFile)\nasync Task EncryptAsync(string sourceFilePath, string destinationFilePath, byte[] key, byte[] iv, bool overwriteExistingFile)\nvoid EncryptWithPassword(string sourceFilePath, string destinationFilePath, string password, bool overwriteExistingFile)\nasync Task EncryptWithPasswordAsync(string sourceFilePath, string destinationFilePath, string password, bool overwriteExistingFile)\n\n// methods for decryption of files\nvoid Decrypt(string sourceFilePath, string destinationFilePath, byte[] key, byte[] iv, bool overwriteExistingFile)\nasync Task DecryptAsync(string sourceFilePath, string destinationFilePath, byte[] key, byte[] iv, bool overwriteExistingFile)\nvoid DecryptWithPassword(string sourceFilePath, string destinationFilePath, string password, bool overwriteExistingFile)\nasync Task DecryptWithPasswordAsync(string sourceFilePath, string destinationFilePath, string password, bool overwriteExistingFile)\n``` \n\n---\n\n### Static class AesEncryptionAdditionalData\n\nFrom v2 this class can be used for adding additional data to encrypted package. Added additional data is\nencrypted with hard-coded key and IV, so it's not realy secure. It can be used for embedding password hint\ninto the package or any other data that can fit into Dictionary\u003cstring, string\u003e. Note that additional data\nis Dictionary\u003cstring, string\u003e and **entries where key or value is null or empty will be ignored**. This\nmight be a chance for improvement. Also note that encrypted data with embedded additional data can be\nnormally decrypted as encrypted data without embedded additional data. Here are available methods:\n\n```csharp\n// methods for adding additional data\nstatic string AddAdditionalData(string encryptedData, Dictionary\u003cstring, string\u003e additionalData)\nstatic byte[] AddAdditionalData(byte[] encryptedData, Dictionary\u003cstring, string\u003e additionalData)\nstatic void AddAdditionalData(Stream encryptedData, Dictionary\u003cstring, string\u003e additionalData, Stream destination)\n\n// methods for reading additional data\nstatic Dictionary\u003cstring, string\u003e ReadAdditionalData(string encryptedData)\nstatic Dictionary\u003cstring, string\u003e ReadAdditionalData(byte[] encryptedData) \nstatic Dictionary\u003cstring, string\u003e ReadAdditionalData(Stream encryptedData)\n```\n\n---\n\n### Class CryptoRandom : IDisposable\n\nEvery method in CryptoRandom class has static equivalent method which is called [MethodName]Static.\nThis class is disposable and if you are generating multiple random values it's recommended to use \ninstance methods of one instance instead of calling static methods.\n\nAvailable methods and properties:\n\n```csharp\nstatic CryptoRandom Default { get; } // default instance\n\nbyte[] NextBytes(uint length)\n\nint NextInt() =\u003e NextInt(0, int.MaxValue)\nint NextInt(int maxExclusive) =\u003e NextInt(0, maxExclusive)\nint NextInt(int minInclusive, int maxExclusive)\n\nstatic double NextDoubleStatic()\ndouble NextDouble()\n\nvoid FillIntArrayWithRandomValues(int[] arrayToFill, int minInclusive, int maxExclusive)\n\nvoid Dispose()\n```\n\n---\n\n### Class ThreadSafeRandom\n\nThread safe random is inheriting `System.Random` but all methods are thread safe.\nThis class does not have crypto level of randomness.\n\n```csharp\npublic class ThreadSafeRandom : System.Random\n{\n    int Next();\n    int Next(int maxValue);\n    int Next(int minValue, int maxValue);\n    void NextBytes(byte[] buffer);\n    double NextDouble()\n}\n```\n\n---\n\n### Class PasswordGenerator : IDisposable\n\nPasswordGenerator has static methods in the same manner as CryptoRandom, following examples will\nshow only calls to instance methods.\n\n```csharp\nusing (var pg = new PasswordGenerator())\n{\n    string pass1 = pg.Generate(); // 16 chars, includes symbols, numbers, lower and upper case letters\n    string pass2 = pg.Generate(8); // 8 chars, includes symbols, numbers, lower and upper case letters\n    string pass3 = pg.Generate(\n        PasswordGenerationOptions.Default\n            .SetMinNumbers(4)   // at least one number\n            .SetMinSymbols(4)   // at least one symbol\n            .UseSymbols(\"!@#$\") // only those symbols will be used\n            .SetLength(12)      // 12 chars output\n            // always call SetLength last it will lower the number of min values for \n            // number, symbols, lower case and upper case if needed\n            // otherwise you could get an exception thrown\n        );\n    )\n}\n```\n\n---\n\n### PasswordHasherAndValidator\n\nNew password hasher, recommended to be used for new implementations instead of `PasswordHasher`.\n\n```csharp\n// constructors:\nPasswordHasherAndValidator() // 64 bytes of salt, 64 bytes of hash and 28000 iterations\nPasswordHasherAndValidator(int iterations) // 64 bytes of salt, 64 bytes of hash and x iterations (must be at least 25000)\n\n// methods:\nstring HashPasswordToString(string password);\nbyte[] HashPassword(string password);\nPasswordHashValidationResult ValidatePassword(string password, string hashWithEmbeddedSalt);\nPasswordHashValidationResult ValidatePassword(string password, byte[] hashWithEmbeddedSalt);\n```\n\nValidation result enum:\n\n```csharp\npublic enum PasswordHashValidationResult\n{\n    Valid,\n    NotValid,\n    ValidShouldRehash\n}\n```\n\n`PasswordHashValidationResult.ValidShouldRehash` value is returned in case when original hash was created with lesser\nnumber of iterations when compared to current instance of `PasswordHasherAndValidator`.\n\n---\n\n### Class PasswordHasher\n\nThis class can be used for hashing and validating passwords. It is recommended to use `PasswordHasherAndValidator`\nfor new implementations.\n\n```csharp\n// constructors:\n\nPasswordHasher() // 32 bytes of salt, 32 bytes of hash and 25000 hash iterations\nPasswordHasher(uint hashAndSaltLengthsInBytes) // 25000 hash iterations\nPasswordHasher(uint hashAndSaltLengthsInBytes, uint hashIterations)\n\n\n// methods:\n\nbyte[] GenerateRandomSalt()\n\nbyte[] HashPassword(string password, byte[] salt)\nbyte[] HashPasswordAndGenerateSalt(string password, out byte[] salt)\nbool ValidatePassword(string password, byte[] hash, byte[] salt)\n\nbyte[] HashPasswordAndGenerateEmbeddedSalt(string password)\nbool ValidatePasswordWithEmbeddedSalt(string password, byte[] hashAndEmbeddedSalt)\n\nstring HashPasswordAndGenerateEmbeddedSaltAsString(string password)\nbool ValidatePasswordWithEmbeddedSalt(string password, string hashAndEmbeddedSalt)\n```\n\n---\n\n### Class TokenGenerator\n\nThis class can used for generating random string tokens for e.g. password reset, email address confirmation, etc... It also provides methods for \nhashing tokens and validating token hashes (it's not recommended to store plain text tokens in db)\n\n```csharp\n// default chars used for token generation\nconst string DefaultAllowedChars = \"qwertyuiopasdfghjklzxcvbnm1234567890QWERTYUIOPASDFGHJKLZXCVBNM\";\n\n// constructors:\n\nTokenGenerator() // default constructor; uses DefaultAllowedChars\nTokenGenerator(string allowedChars) // Constructor that allows defining allowed characters to be used for token generation\n// allowedChars parameter must have at least 10 distinct characters, white space characters are ignored\n\n// methods:\n\n// Generates random string token of desired length\n// Parameter length must be greater than 0\nstring GenerateToken(int length)\n\n// Hashes token (with random salt) so you don't have to store plain text token\nstring HashToken(string token)\n\n// Hashes token with SHA256 if quickHash is true (suitable for long random tokens with short expiry time), if false it works the same as HashToken(string)\nstring HashToken(string token, bool quickHash)\n\n// Validates token hash that is created by calling HashToken(string) or HashToken(string, bool)\nbool ValidateTokenHash(string token, string hash)\n```\n\n---\n\n### Class IdGenerator\n\nThis class generates identifiers that are by default:\n- shorter than GUIDs (both as strings and as bytes)\n- mostly incremental\n\nIdGenerator generates identifiers in following format:\n\n```\n{timeBasedPart, 8 chars}{fixedPart, default is empty}{randomPart 4-100 chars, default is 6}\n```\n\nIdGenerator can optional add fixed part between time based part and random part and can optionally\nadd hyphens between parts. Optional fixed part is useful if you want to know which (micro)service has \ngenerated specific ID (where each service, or service instance has specific fixed part set)\n\nHow it works:\n- Custom base 55 charset (numbers and English alphabet lower case and upper case excludes chars `I`, `i`,\n`O`, `o`, `l`, `0` and `1`) is defined for converting time and generating random parts\n- Time base part is generated by taking `DateTime.UtcNow` or overridden time and calculating total miliseconds\nsince `UTC 2010-01-01 00:00`, that value is converted to chars with custom base 55 charset\n- Fixed part (if defined) is appended\n- Random part is generated and appended\n\nSome examples of generated identifiers:\n```\ndefault generator:                   2Qj4AbNMz7NHzP\nwith hyphens:                        2Qj4AbNM-z7NHzP\nwith fixed part (ABC):               2Qj4AbNMABCz7NHzP\nwith fixed part (ABC) and hyphens:   2Qj4AbNM-ABC-z7NHzP\nwith longer random part:             2Qj4AbNMABCqAAA9N7F5aBUSm3z\nwith longer random part and hyphens: 2Qj4AbNM-ABC-qAAA9N7F5aBUSm3z\n```\n\nConstructors:\n```csharp\n// Default constructor, FixedPart = \"\", FastRandom = true\nIdGenerator() : this(\"\", true)\n{\n}\n\n// Constructor to accept boolean value telling the generator to use or not to use fast random\n// If fastRandom is true System.Random is used, otherwise EasyCrypto.CryptoRandom is used\nIdGenerator(bool fastRandom): this(\"\", fastRandom)\n{\n}\n\n// Constructor to accept boolean value telling the generator to use or not to use fast random and fixed part of generated id\n// fixedPart is fixed part to set in middle of generated id\n// If fastRandom is true System.Random is used, otherwise EasyCrypto.CryptoRandom is used\nIdGenerator(string fixedPart, bool fastRandom)\n{\n    FixedPart = (fixedPart ?? \"\").Trim();\n    FastRandom = fastRandom;\n}\n```\n\nProperties:\n```csharp\n// Default instance of Id generator with FastRandom = true, FixedPart = \"\", RandomPartLength = 6 and AddHyphens = false\nstatic IdGenerator Default { get; } = new IdGenerator();\n// Warning: Default is static property, changing it's properties will affect every call of IdGenerator.Default\n\n// Length of random part, default value is 6, must not be less than 4 or greater than 100\nint RandomPartLength { get; set; }\n\n// If true hyphens (-) are added between parts\nbool AddHyphens { get; set; }\n```\n\nMethods:\n```csharp\n// Generates new id string where for time part current UTC time is used\nstring NewId() =\u003e NewId(DateTime.UtcNow);\n\n// Generates new id using specified time\n// warning: when using this override, make sure to specify very precise time, including milliseconds\nstring NewId(DateTime time);\n```\n\nUsage examples:\n```csharp\nstring id1 = IdGenerator.Default.NewId(); // example: 2Qj4AbNMz7NHzP\n\nvar gen0 = new IdGenerator();\nstring id0  = gen0.NewId(); // example: 2Qj4AbNMz7NHzP\n\nvar gen1 = new IdGenerator { AddHyphens = true };\nstring id1  = gen1.NewId(); // example: 2Qj4AbNM-z7NHzP\n\nvar gen2 = new IdGenerator(\"ABC\", true) { AddHyphens = true };\nstring id2 = gen2.NewId(); // example: 2Qj4AbNM-ABC-z7NHzP\n\nvar gen3 = new IdGenerator(\"ABC\", true) { AddHyphens = true, RandomPartLength = 16 };\nstring id3 = gen3.NewId(); // example: 2Qj4AbNM-ABC-qAAA9N7F5aBUSm3z\n\n// example with specific time\nDateTime specificTime = new DateTime(2011, 01, 08, 16, 35, 37, 461, DateTimeKind.Utc);\nstring idWithSpecificTime1 = gen0.NewId(specificTime); // 2EZ7UwPZatcZCe\nstring idWithSpecificTime2 = gen0.NewId(specificTime); // 2EZ7UwPZanDYS8\n// warning: make sure when using specific time to use very precise time, including milliseconds\n```\n\n---\n\n### Static Class RsaEncryption\n\nThis class can be used for asymmetric encryption. Public key can be used for encryption and private key for decryption.\nIt's not recommended to store private keys in plain text on disk. Data that is passed to encryption methods must be \nsmaller than the key size used.\n\n```csharp\n// Methods for generating key pairs\nstatic RsaKeyPair GenerateKeyPairs() =\u003e GenerateKeyPairs(RsaKeySizes.Rsa2048);\nstatic RsaKeyPair GenerateKeyPairs(RsaKeySizes keySize)\n\n// encryption methods\nstatic byte[] Encrypt(byte[] data, RsaPublicKey key)\nstatic string Encrypt(string data, RsaPublicKey key)\n\n// decryption methods\nstatic byte[] Decrypt(byte[] data, RsaPrivateKey key)\nstatic string Decrypt(string data, RsaPrivateKey key)\n```\n\nExample for usage of RsaEncryption:\n\n```csharp\n[Fact]\npublic void String_EncryptDecrypt_GivesEqualString()\n{\n    var keys = RsaEncryption.GenerateKeyPairs();\n\n    var plainText = Guid.NewGuid().ToString();\n    string encrypted = RsaEncryption.Encrypt(plainText, keys.PublicKey);\n    string decrypted = RsaEncryption.Decrypt(encrypted, keys.PrivateKey);\n    \n    Assert.Equal(plainText, decrypted);\n}\n```\n\n### Class QuickEncryption\n\nWhen encrypting short data with password this class provides 3000x-5000x faster encryption and decryption compared\nto `AesEncryption` password methods. It must be used with `QuickEncryptionKey` which is randomly generated.\n`QuickEncryptionKey` can be stored as plain text using `ToString()` method which returns string representation\nof the key. String representation can be parsed with `Parse(string)` method.\n\n`QuickEncryptionKey` has static methods:\n\n```csharp\nQuickEncryptionKey CreateNew() // creates new random key\nQuickEncryptionKey Parse(string s) // parses existing key\nToString() // converts key to string which can be parsed\n```\n\nQuickEncryption constructor:\n\n```csharp\npublic QuickEncryption(QuickEncryptionKey key)\n```\n\nQuickEncryption methods:\n\n```csharp\nbyte[] Encrypt(byte[] plainTextData)\nstring Encrypt(string plainText)\nbyte[] Decrypt(byte[] data)\nstring Decrypt(string encryptedData)\n\nstatic byte[] Encrypt(byte[] plainTextData, QuickEncryptionKey key)\nstatic string Encrypt(string plainText, QuickEncryptionKey key)\nstatic byte[] Decrypt(byte[] data, QuickEncryptionKey key)\nstatic string Decrypt(string encryptedData, QuickEncryptionKey key)\n```\n\nStatic methods can be used with any key, instance methods are used with key provided in constructor.\n\nExample:\n\n```csharp\nQuickEncryptionKey key = QuickEncryptionKey.CreateNew();\n// you can call `key.ToString()` to save key and later call `QuickEncryptionKey.Parse(string)` to get it back\n\nstring encrypted = QuickEncryption.Encrypt(\"some text to encrypt\", key);\nstring decrypted = QuickEncryption.Decrypt(encrypted, key);\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanac%2FEasyCrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstanac%2FEasyCrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstanac%2FEasyCrypto/lists"}