{"id":25020678,"url":"https://github.com/panoramicdata/panoramicdata.encryption","last_synced_at":"2025-03-30T10:25:49.237Z","repository":{"id":98576936,"uuid":"477808455","full_name":"panoramicdata/PanoramicData.Encryption","owner":"panoramicdata","description":"An easy-to-use encryption service.","archived":false,"fork":false,"pushed_at":"2024-01-03T09:47:49.000Z","size":48,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-06T22:04:22.447Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/panoramicdata.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":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-04-04T17:40:18.000Z","updated_at":"2022-04-04T18:13:04.000Z","dependencies_parsed_at":"2024-01-03T10:48:01.585Z","dependency_job_id":"34588036-fac1-4c5f-a593-768a0126c697","html_url":"https://github.com/panoramicdata/PanoramicData.Encryption","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/panoramicdata%2FPanoramicData.Encryption","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panoramicdata%2FPanoramicData.Encryption/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panoramicdata%2FPanoramicData.Encryption/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panoramicdata%2FPanoramicData.Encryption/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panoramicdata","download_url":"https://codeload.github.com/panoramicdata/PanoramicData.Encryption/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246304226,"owners_count":20755866,"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":[],"created_at":"2025-02-05T12:17:07.098Z","updated_at":"2025-03-30T10:25:49.218Z","avatar_url":"https://github.com/panoramicdata.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PanoramicData.Encryption\n\nAlthough you could use the nuget package, why would you trust it?\nBetter to read and understand and copy the source into your project.\n\nSeriously, there's only one file.  Copy it.  It's [here](https://raw.githubusercontent.com/panoramicdata/PanoramicData.Encryption/main/PanoramicData.Encryption/EncryptionService.cs).\n\nTo use:\n\n```C#\n   using PanoramicData.Encryption;\n\n   // Preparation\n\n   // Here is the plaintext we want to protect:\n   var plaintext = \"Hello, World!\";\n   \n   // The encryption key should be a 32 byte array,\n   // represented as a 64 character hex string.\n   // NO NOT use this one.  It will work, but it is not secure.\n   // DO NOT store your encryption keys in your source code.\n   // Environment variables are one way to keep your data, keys and source code separate.\n   // You could use var privateKey = Environment.GetEnvironmentVariable(\"PrivateKey\") method to retrieve this.\n   // So we have a working example, let's put it in code for now.\n   var privateKey = \"00112233445566778899AABBCCDDEEFF00112233445566778899AABBCCDDEEFF\";\n\n   // Create the encryption service using the private key.\n   var encryptionService = new EncryptionService(privateKey);\n\n\n   // Encryption\n\n   // EITHER 1) create cipherText and salt at the same time.\n   // This is the recommended way to do it.\n   (var cipherText, var salt) = encryptionService.Encrypt(plaintext);\n\n   // OR 2) create your own salt first:\n   var salt = \"00112233445566778899AABBCCDDEEFF\";\n   (var cipherText2, var _) = encryptionService.Encrypt(plaintext, salt);\n\n   // Storage\n   // You should store the salt and cipherText in your database.\n   // You may prefer to Base64 encode them before storing them, for storage efficiency.\n\n   // ...\n\n   // Retrieval\n   // The salt and cipherText are safe for anyone to have access to.\n   // Without the private key, no-one cannot decrypt the data.\n   // Retrieve them from storage...\n\n   // Decryption\n\n   // You can decrypt the cipherText using the EncryptionService and the salt:\n   var restoredPlainText = encryptionService.Decrypt(cipherText, salt);\n\n   Console.WriteLine(restoredPlainText);\n\n   // Worst.  \"Hello, World!\"  Ever.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanoramicdata%2Fpanoramicdata.encryption","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanoramicdata%2Fpanoramicdata.encryption","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanoramicdata%2Fpanoramicdata.encryption/lists"}