public static void GenerateKeyAndSave(string file) { var p = GetRandomKey(); RSAParametersWithPrivate t = new RSAParametersWithPrivate(); t.SetParameters(p); File.WriteAllText(file, JsonConvert.SerializeObject(t)); }
public static void GenerateRsaKeys(string webRootPath) { var rsaKey = new RSACryptoServiceProvider(2048); var publicKey = rsaKey.ExportParameters(true); var rSaParametersWithPrivate = new RSAParametersWithPrivate(); rSaParametersWithPrivate.SetParameters(publicKey); ToJson(rSaParametersWithPrivate, webRootPath); }
public static void GenerateKeyAndSave(string file) { var p = GetRandomKey(); RSAParametersWithPrivate t = new RSAParametersWithPrivate(); t.SetParameters(p); System.IO.File.WriteAllText(file, JsonConvert.SerializeObject(t)); }
private static void ToJson(RSAParametersWithPrivate exportParameters, string webRootPath) { using (var file = new FileStream(Path.Combine(webRootPath, "RsaKey.json"), FileMode.Create)) { using (var stream = new StreamWriter(file)) { var content = JsonConvert.SerializeObject(exportParameters); stream.Write(content); } } }
public RsaKeyService GenerateKeyAndSave(bool forceUpdate = false) { if (forceUpdate || NeedsUpdate()) { var p = GetRandomKey(); RSAParametersWithPrivate t = new RSAParametersWithPrivate(); t.SetParameters(p); File.WriteAllText(_file, JsonConvert.SerializeObject(t, Formatting.Indented)); } return(this); }
public RsaKeyService GenerateKeyAndSave(bool forceUpdate = false) { //if (forceUpdate || NeedsUpdate()) { if (forceUpdate) { var p = GetRandomKey(); RSAParametersWithPrivate t = new RSAParametersWithPrivate(); t.SetParameters(p); File.WriteAllText(_file, JsonSerializer.Serialize(t, new JsonSerializerOptions { WriteIndented = true, PropertyNameCaseInsensitive = true })); } return(this); }
public static RSAParameters AnimeciKey() { var keyParams = new RSAParametersWithPrivate(); keyParams.D = GetStrBytes("GUCTc82wxFito0VvPQmXnpxZvj0PBz0jF/1mH63BpIdc/0tFuCfqbPYcy6fxJ7YsNnWF+CUZ86CrcOrD6MGbreCwUe+VruAqJd0Vn9emQfD7obXuIIasbJGdSoovCicYkRJGsOBC40VDHdFncSoOokLND2Pc3QsFPVc1mT/M+c9e5AKa4T4M2rtAIFfWe9UbOg83Kogi0XDTisUxM+W7IVX1m6KnvJE4sKOLpawYqp2AdfGh19TGqXrQRoGV204VbBXzNBtHT3GANDqcPRr4d44v01jWMXTwvhI734V268Omdkco4yyMjt7oR2PjBx6Vq8fbbIPBDuTWy3NzCtRAAQ=="); keyParams.DP = GetStrBytes("rg6EXA9T+muJjAsbIFamDpjS3D0DXWBhU03SJUiCtd93XimWdcqlCi7WpXCGr9uJgOMRng6fjWw8amoulP2vzUQM4Rf2e+9bMX+tB/JvsA6Zyi5TVa2o2wvPmMbBg/zKYYQVmTGve7on4jNOAD0PywAZvQR97BvPf6J1VkopthE="); keyParams.DQ = GetStrBytes("EiZX52P3qSzUSLdvx5R6ocZ9sqKEMHfXlhiWr0s6eZfc4JEhMhxpJVoH46zbtZc6Gf1lhOhX9y5i6B6l6UBvzj581prFxEBnxO2Lc9JPzm0v8p5++QrkuExyIOuhMbL7GMnfYEEMfkcOKMaVdSfVFXJGYZiH3r8uFkUagswdIz0="); keyParams.Exponent = GetStrBytes("AQAB"); keyParams.InverseQ = GetStrBytes("J58MzZ56XwXENQNTqbE+ckNFJO6rR0bHHIbr1BHn4thG4DYK9Y/2w2FHJenI8pAQfGqHszDexpS8rfguryNr8hUJnWDNQL0w9MXfzLzm73lB3NHZ4xr7FpGdtGrhziQv5oKeQ8s99e4RUOYeOeKTdKgd1fYxojeskVq/A05NrAI="); keyParams.Modulus = GetStrBytes("qh9+Ao5voe7J/6jofHFivf/MfTtL5w6Wc2GicwyqliG5cDe1/CX2cbLId7QgaXS8HzQd1VgOH9vD1Mt+1FsQaFNSLKEK6CdlNhXGp+2iW48YEiV4K36oFdfWorkYHTbO86dctut3rAECm3zFHsa7RYLt89BSjNbMAm7QbuEBhB7su+xAZKcM31UUKQLbbelbGck89joStZNAmhdVwUQsgvaA7qPGCxwoJGI5U0Anx4Qf/nIUYcttYyh8JigtbgtArpBsZ9QS8pRy7Ch7BQVE6t6w5NDjid/YahS2p731S8FxMk+qoMJmaTc2rm2Z2iIndkk1s1v9VKE7dkK1U9f7uw=="); keyParams.P = GetStrBytes("uCrlH/XABMJjRFwqJ8JtPjHCoLxV3NOG0PUqNSeEO1gAwC0vhAL4k4SfRjSdaBF2vdXpHZTij2SR7QX1vPyvNLvM4vXPZxEBDJjedVYi6x/6Jpho/0wfGbChcPaS2AN3Dh/tvKs6k3Nwoe5zokpfAPAR6MGjuhd3UwvSDz/C5bE="); keyParams.Q = GetStrBytes("7HpAa0eCc0AZhqcpyQwFnIHbNadiLMnz4klT+FyDwdLuaY5KEF44EuQSNI+x81LxTW+jSRPkskA7xquEOBqE3qDHxCDLh2Ny/OlSAohg8OJL7MjPOC5NUZewECwUoQoeHi3QRGyLnt68tW0hRZZ0603cKeG9zNp7cUAQsDqglys="); return(keyParams.ToRSAParameters()); }