示例#1
0
        static void QuodEratDemonstrandum()
        {
            bool           AliceToBob = true;
            LicenseService Bob        = new LicenseService();

            if (AliceToBob)
            {
                using (LicenseGenerator Alice = new LicenseGenerator()) {
                    string text64 = Bob.EncryptSessionKeyByRSA("How can it be", Alice.Public_KeyUsed);
                    byte[] buff   = Convert.FromBase64String(text64);
                    Report("Local Result = [{0}]", Alice.DecryptSessionKeyByRSA(text64));
                }
            }
            else
            {
                using (LicenseGenerator Alice = new LicenseGenerator()) {
                    string text64 = Alice.EncryptSessionKeyByRSA("How can it be", Bob.GetPublicKey());
                    Report("Result = [{0}]", Bob.DecryptSessionKeyByRSA(text64));
                }
            }
        }
示例#2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!String.IsNullOrEmpty(Request.QueryString["days"]))
     {
         try{
             using (LicenseGenerator Lg = new LicenseGenerator()){
                 double   value  = double.Parse(Request.QueryString["days"]);
                 DateTime test   = DateTime.Today.AddDays(value);
                 DateTime expire = new DateTime(test.Year, test.Month, test.Day, 23, 59, 59);
                 string   text   = Lg.EncryptSessionKeyByRSA(String.Format("{0} {1}", expire.ToLongDateString(), expire.ToLongTimeString()));
                 Report("{0}", String.Format("//試用期限{0:yyyy年MM月dd日}までのライセンス・キーです。", expire));
                 Report(@"COM1.LicenseKey=COM2.LicenseKey=""{0}"";", text);
             }
         }catch (Exception ex) {
             Report(ex);
         }
     }
     else
     {
         Response.Redirect("LicenseService.asmx");
     }
 }
示例#3
0
 public string EncryptSessionKeyByRSA(string text, string keyToUse)
 {
     using (LicenseGenerator Lg = new LicenseGenerator()){
         return(Lg.EncryptSessionKeyByRSA(text, keyToUse));
     }
 }