Initial commit

This commit is contained in:
Tony Bark 2025-03-23 00:56:57 -04:00
commit e03cd1dcca
14 changed files with 863 additions and 0 deletions

44
QuickDB/DemoDB.cs Normal file
View file

@ -0,0 +1,44 @@
namespace QuickDB;
public static class DemoDB
{
public static void CreateFetch(string value)
{
// Prompt the user for input
Console.WriteLine($"Stored value: {value}");
// Hash the input string
string hashedKey = ComputeSHA256Hash(value);
// Store the hashed key and original input value in a dictionary
Dictionary<string, string> hashDictionary = new Dictionary<string, string>();
hashDictionary[hashedKey] = value;
// Display the hashed key
Console.WriteLine($"Hashed Key: {hashedKey}");
// Retrieve the original input value using the hashed key
if (hashDictionary.TryGetValue(hashedKey, out string retrievedValue))
Console.WriteLine($"Retrieved Value: {retrievedValue}");
else
Console.WriteLine("Key not found in dictionary.");
}
// Method to compute SHA256 hash from a string
static string ComputeSHA256Hash(string rawData)
{
// Create a SHA256 instance.
using SHA256 sha256Hash = SHA256.Create();
// Compute the hash of the input string.
byte[] bytes = sha256Hash.ComputeHash(Encoding.UTF8.GetBytes(rawData));
// Convert byte array to a string (hexadecimal).
StringBuilder builder = new StringBuilder();
for (int i = 0; i < bytes.Length; i++)
{
builder.Append(bytes[i].ToString("x2"));
}
return builder.ToString();
}
}

2
QuickDB/GlobalUsing.cs Normal file
View file

@ -0,0 +1,2 @@
global using System.Security.Cryptography;
global using System.Text;

9
QuickDB/QuickDB.csproj Normal file
View file

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
</Project>