/// <summary> /// ใช้สร้าง Base58 Private Key และ Public Key รูปแบบ ECDsa Cng ตาม Algorithm ที่กำหนด https://www.nuget.org/packages/System.Security.Cryptography.Cng/ /// </summary> /// <param name="alg"></param> /// <returns></returns> public static KeyPairs GenerateBase58CngKeyPairs(CngAlgorithm alg) { var keyPairs = new KeyPairs(); var key = CngKey.Create(alg, "stn.auth.api", new CngKeyCreationParameters { KeyCreationOptions = CngKeyCreationOptions.OverwriteExistingKey, KeyUsage = CngKeyUsages.AllUsages, ExportPolicy = CngExportPolicies.AllowPlaintextExport }); keyPairs.PrivateKey = Base58Encoding.Encode(key.Export(CngKeyBlobFormat.EccPrivateBlob)); keyPairs.PublicKey = Base58Encoding.Encode(key.Export(CngKeyBlobFormat.EccPublicBlob)); key.Dispose(); return(keyPairs); }
public override string ToString() { return("[{" + String.Join("},{", KeyPairs.Select(vp => vp.Key.ToString() + "," + vp.Value).ToArray()) + "}]"); // Not L10N }