Skip to content

Instantly share code, notes, and snippets.

View MovGP0's full-sized avatar
🌱

Johann Dirry MovGP0

🌱
View GitHub Profile
@MovGP0
MovGP0 / Asymmetric Encryption
Created June 30, 2015 13:32
Encryption in .NET
// Used to exchange symmetric keys
private static int RsaKeySize = 2048;
private void CreateKeys()
{
using(var provider = new RSACryptoServiceProvider(RsaKeySize))
{
provider.PersistKeyInCsp = false;
/// <summary>Takes a list of values and scales the values, so that the sum of the result is always 1 (100%).</summary>
/// <param name="values">A list of values that need to be scaled.</param>
/// <returns>Scaled values, from which the sum is 1.</returns>
let scaleSoThatSumIsOne (values:seq<decimal>) =
let Σ = Seq.sum values
match Σ with
| 0.0m ->
let n = decimal (Seq.length values)
seq {
for p in values do