![]() |
VOOZH | about |
dotnet add package Bytehide.Storage --version 1.0.0.5
NuGet\Install-Package Bytehide.Storage -Version 1.0.0.5
<PackageReference Include="Bytehide.Storage" Version="1.0.0.5" />
<PackageVersion Include="Bytehide.Storage" Version="1.0.0.5" />Directory.Packages.props
<PackageReference Include="Bytehide.Storage" />Project file
paket add Bytehide.Storage --version 1.0.0.5
#r "nuget: Bytehide.Storage, 1.0.0.5"
#:package Bytehide.Storage@1.0.0.5
#addin nuget:?package=Bytehide.Storage&version=1.0.0.5Install as a Cake Addin
#tool nuget:?package=Bytehide.Storage&version=1.0.0.5Install as a Cake Tool
_____ __
/ ___// /_____ _________ _____ ____
\__ \/ __/ __ \/ ___/ __ `/ __ `/ _ \
___/ / /_/ /_/ / / / /_/ / /_/ / __/
/____/\__/\____/_/ \__,_/\__, /\___/
/____/
This sample demonstrates how to use the Bytehide Storage SDK for performing various tasks such as uploading, downloading, compressing, and encrypting files. The example includes:
Bytehide.Storage NuGet package./<bucket_name>/images/ for image uploads./<bucket_name>/texts/ for text uploads./<bucket_name>/models/ for model uploads.Add the ByteHide.Storage SDK to your .NET project via NuGet:
NuGet\\Install-Package Bytehide.Storage
Once the package is installed, start integrating it into your project.
Initialize the StorageManager with your project token.
var storage = new StorageManager();
🔴 Note: Create your environment variables:
BYTEHIDE_STORAGE_TOKEN your project token.BYTEHIDE_STORAGE_PHRASE_ENCRYPTION your encryption phrase.Or
var storage = new StorageManager("<project_token>", "<phrase_encryption>");
🔴 Note: Consider using a secure method to store the project token and encryption phrase, such as ByteHide Secrets.
The library supports various quantum algorithms designed to protect data against quantum computing threats. These algorithms adhere to post-quantum cryptographic standards. Below is a list of the supported algorithms, along with brief descriptions of each:
public enum QuantumAlgorithmType
{
Kyber512,
Kyber768,
Kyber1024,
Sntrup761,
FrodoKem1344Shake,
MlKem512,
MlKem768,
MlKem1024
}
To set a quantum algorithm, use the following code:
var storage = new StorageManager(QuantumAlgorithmType.Kyber1024);
🔴 Note: The default quantum algorithm is Kyber1024.
Kyber512, Kyber768, Kyber1024
Kyber is a lattice-based Key Encapsulation Mechanism (KEM), currently recommended by NIST. Variants 512, 768, and 1024 represent increasing levels of security, with Kyber1024 offering the highest level of protection, ideal for applications requiring maximum resistance to quantum attacks.
Sntrup761
Based on NTRU combined with R-LWE (Ring Learning With Errors), Sntrup761 is a fast and secure KEM scheme resistant to quantum attacks. It is designed to balance performance with security, making it suitable for resource-constrained environments.
FrodoKem1344Shake
Part of the FrodoKEM family, this algorithm is based on the LWE problem without using specific algebraic structures. FrodoKem1344Shake leverages the SHAKE hash function to provide a high level of security, suited for scenarios where security is prioritized over speed.
MlKem512, MlKem768, MlKem1024
The MlKem algorithms focus on secure key encapsulation mechanisms using optimized algebraic structures. Versions 512, 768, and 1024 offer different security levels, with MlKem1024 as the most robust, suitable for critical applications demanding high security.
This section shows how to load an image file from the project's embedded resources. ResourceManagerHelper.GetResourceAsBytes()
var image = ResourceManagerHelper.GetResourceAsBytes(Assembly.GetExecutingAssembly(), "Sample.Resources.Images.photo0.jpg");
if (image == null || image.Length == 0)
{
Console.WriteLine("Failed to load the image from resources.");
return;
}
bool uploaded = storage
.In("<bucket_name>/images")
.Set("photo.jpg", image);
Async
bool uploaded = await storage
.In("<bucket_name>/images")
.SetAsync("photo.jpg", image).Result;
This section demonstrates how to upload an image to the storage bucket from the assembly. FromAssembly()
bool uploaded = storage
.In("<bucket_name>/images")
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<path_to_image>");
This section demonstrates how to upload a file to the storage bucket from the local file system. FromFile()
bool uploaded = storage
.In("<bucket_name>/images")
.FromFile("photo.jpg", "<path_to_image>/photo.jpg");
bool uploaded = storage
.In("<bucket_name>/texts")
.FromFile("file.txt", "<path_to_file>/file.txt");
This section demonstrates how to upload a file with compression. Compress()
bool uploaded = storage
.In("<bucket_name>/images")
.Compress()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
bool uploaded = storage
.In("<bucket_name>/images")
.Compress()
.FromFile("photo.jpg", "<path_to_image>/photo.jpg");
bool uploaded = storage
.In("<bucket_name>/texts")
.Compress()
.FromFile("file.txt", "<path_to_file>/file.txt");
This section demonstrates how to upload a file with encryption. Encrypt()
bool uploaded = storage
.In("<bucket_name>/images")
.Encrypt()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
bool uploaded = storage
.In("<bucket_name>/images")
.Encrypt()
.FromFile("photo.jpg", "<path_to_image>/photo.jpg");
bool uploaded = storage
.In("<bucket_name>/texts")
.Encrypt()
.FromFile("file.txt", "<path_to_file>/file.txt");
This section demonstrates how to upload a file with encryption and compression. Encrypt() and Compress()
bool uploaded = storage
.In("<bucket_name>/images")
.Compress()
.Encrypt()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
bool uploaded = storage
.In("<bucket_name>/images")
.Compress()
.Encrypt()
.FromFile("photo.jpg", "<path_to_image>/photo.jpg");
bool uploaded = storage
.In("<bucket_name>/texts")
.Compress()
.Encrypt()
.FromFile("file.txt", "<path_to_file>/file.txt");
This section demonstrates how to upload a file with quantum encryption and compression. EncryptWithQuantum()
bool uploaded = storage
.In("<bucket_name>/images")
.EncryptWithQuantum()
.Compress()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
bool uploaded = storage
.In("<bucket_name>/images")
.EncryptWithQuantum()
.Compress()
.FromFile("photo.jpg", "<path_to_image>/photo.jpg");
bool uploaded = storage
.In("<bucket_name>/texts")
.EncryptWithQuantum()
.Compress()
.FromFile("file.txt", "<path_to_file>/file.txt");
Upload a large text file and apply compression and encryption. The maximum file size is 5 GB.
var largeText = Encoding.UTF8.GetBytes(new string('A', 10000000));
storage
.In("<bucket_name>/texts")
.Compress()
.Encrypt()
.Set("payload.txt", largeText);
With Quantum Encryption
var largeText = Encoding.UTF8.GetBytes(new string('A', 10000000));
storage
.In("<bucket_name>/texts")
.Compress()
.EncryptWithQuantum()
.Set("payload.txt", largeText);
storage
.In("<bucket_name>/images")
.SaveToDisk("photo.jpg", "<path_to_downloaded_image>/photo.jpg");
Download a text file and save it to disk.
storage
.In("<bucket_name>/texts")
.SaveToDisk("payload.txt", "<path_to_downloaded_text>/payload.txt");
Or
storage
.SaveToDisk("<bucket_name>/texts/payload.txt", "<path_to_downloaded_text>/payload.txt");
Download the text file as a string.
string text = storage
.In("<bucket_name>/texts")
.GetText("payload.txt");
Or
string text = storage
.GetText("<bucket_name>/texts/payload.txt");
Async
string text = await storage
.In("<bucket_name>/texts")
.GetTextAsync("payload.txt").Result;
Download the text file as a byte array.
byte[] data = storage
.In("<bucket_name>/texts")
.GetBytes("payload.txt");
Or
byte[] data = storage
.GetBytes("<bucket_name>/texts/payload.txt");
Async
string text = await storage
.In("<bucket_name>/texts")
.GetBytesAsync("payload.txt").Result;
Upload a JSON string as a text file.
const string json = "{\"name\":\"John Doe\",\"age\":30}";
var uploaded = storage
.In("<bucket_name>/models")
.Compress()
.Encrypt()
.Set("json.txt", json);
// Define a simple class Foo for demonstration purposes
private class Foo
{
private string Name { get; }
private int Age { get; }
public Foo(string name, int age)
{
Name = name;
Age = age;
}
public override string ToString() => $"Name: {Name}, Age: {Age}";
}
Download the JSON and deserialize it to a custom Foo object.
var data = storage
.In("<bucket_name>/models")
.Get<Foo>("json.txt");
Async
var data = await storage
.In("<bucket_name>/models")
.GetAsync<Foo>("json.txt").Result;
Name: John Doe, Age: 30
Download the JSON as a string.
string text = storage
.In("<bucket_name>/models")
.GetText("json.txt");
Async
string text = await storage
.In("<bucket_name>/models")
.GetTextAsync("json.txt").Result;
{"name":"John Doe","age":30}
The compression and encryption methods can be chained in any order. The order of the methods does not matter.
storage
.In("<bucket_name>/images")
.Encrypt()
.Compress()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
storage
.In("<bucket_name>/images")
.Compress()
.Encrypt()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
If encryption and quantum encryption are used together, it will be applied the last one.
Encryption:
storage
.In("<bucket_name>/images")
.EncryptWithQuantum()
.Encrypt()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
Quantum Encryption:
storage
.In("<bucket_name>/images")
.Encrypt()
.EncryptWithQuantum()
.FromAssembly("photo.jpg", Assembly.GetExecutingAssembly(), "<my_project_>.Resources.<image_path>");
- The compressed files are detected automatically and decompressed during download.
- The encrypted files are detected automatically and decrypted during download.
ByteHide.Storage is licensed under MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.