Пример #1
0
        public static void ExportDemo(string path, string userId, int ID)
        {
            // initialize the KeyStore
            KeyStore ks = new KeyStore(@path, "changeit");

            // should the exported files be ASCII or binary
            bool asciiArmored = true;

            // export public key having the specified userId
            // all public sub keys are exported too



            ks.ExportPublicKey(@"C:/Users/Dua'a-Orcas/Desktop/WebApplication1/WebApplication1/WebApplication1/PageStudents/Sig/" + ID + ".asc", userId, asciiArmored);

            // export secret key having the specified userId, this is usually our own key
            // all secret sub keys are exported too
            ks.ExportPrivateKey(@"C:/Users/Dua'a-Orcas/Desktop/WebApplication1/WebApplication1/WebApplication1/PageStudents/Sig/" + ID + "pr" + ".asc", userId, asciiArmored);

            // export both public and secret key with all sub keys in one file
            // the file is in ASCII armored format by default
            // ks.ExportKeyRing(@"DataFiles\keypair.asc", "*****@*****.**");
        }
Пример #2
0
        public void ExportDemo(string path, string userId, int ID)
        {
            // initialize the KeyStore
            KeyStore ks = new KeyStore(@path, "changeit");

            // should the exported files be ASCII or binary
            bool asciiArmored = true;

            // export public key having the specified userId
            // all public sub keys are exported too

            string pathPub = System.Web.HttpContext.Current.Server.MapPath("../PageStudents/Sig") + "/" + ID + ".asc";
            string pathPri = System.Web.HttpContext.Current.Server.MapPath("../PageStudents/Sig") + "/" + ID + "pr.asc";

            ks.ExportPublicKey(@pathPub, userId, asciiArmored);

            // export secret key having the specified userId, this is usually our own key
            // all secret sub keys are exported too
            ks.ExportPrivateKey(@pathPri, userId, asciiArmored);

            // export both public and secret key with all sub keys in one file
            // the file is in ASCII armored format by default
            // ks.ExportKeyRing(@"DataFiles\keypair.asc", "*****@*****.**");
        }
Пример #3
0
 /// <summary>
 /// Copies the private key for the specified user id to the specified file.
 /// </summary>
 /// <param name="fileName">Full path to output file.</param>
 /// <param name="userId">String representing the user id for the key to export.</param>
 /// <param name="asciiArmored">If true, output will be ascii armored; otherwise output will be in binary.</param>
 public void ExportPrivateKey(string fileName, string userId, bool asciiArmored)
 {
     _keyStore.ExportPrivateKey(fileName, userId, asciiArmored);
 }