Friday, 2 August 2013

Computer Tricks and Tips for System: Security token Key Generagor in C#

Computer Tricks and Tips for System
Computer Tricks, Computer Tricks and Tips for System, computer tips, computer, tips, information, listing, tip, computer tip, about, windows, internet, internet, ticks, explorer, Microsoft --- Computer tips and tricks that help make you more productive and your overall computer experience a lot more enjoyable, Windows 8, Mobile, iPad, Computer Tricks and Tips for System 
Security token Key Generagor in C#
Aug 2nd 2013, 13:20, by Girish Dubey

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;

 

namespace XSLT_Demo

{

    public partial class WebForm1 : System.Web.UI.Page

    {

        protected void Page_Load(object sender, EventArgs e)

        {

            string TokenKey = uniqueTokenKey();

            Response.Write("Unredable : " + TokenKey + "<br />");

            Response.Write("..Redable : " + ReaduniqueTokenKey(TokenKey) + "<br />");

        }

 

 

        private string uniqueTokenKey()

        {

            Random rnd = new Random();

            byte[] bytes = new byte[32];

            rnd.NextBytes(bytes);

            string myRndID = BitConverter.ToString(bytes);

            string[] myRndIDarr = myRndID.Split('-');

 

            string datekey = "";

            datekey = DateTime.Now.ToString("{.1}");

            string rekey = "";

            for (int i = datekey.Length; i > 0; i--)

            {

                rekey += datekey.Substring(i - 1, 1);

            }

            string[] Keyarr = rekey.Split('-');

 

 

            string finalkey = "";

            for (int i = 0; i < Keyarr.Length; i++)

            {

                finalkey += myRndIDarr[i] + "-" + myRndIDarr[i + 1] + "-" + Keyarr[i] + "" + "-";

            }

 

            return finalkey.Replace("-", "");

        }

 

 

        private string ReaduniqueTokenKey(string key)

        {

            string rekey = "";

            rekey = key.Substring(42, 3) + ":" + key.Substring(36, 2) + ":" + key.Substring(12, 2) + ":" + key.Substring(18, 2) + ":" + key.Substring(24, 2) + ":" + key.Substring(30, 2) + ":" + key.Substring(4, 4);

            string readablevalue = "";

 

            for (int i = rekey.Length; i > 0; i--)

            {

                readablevalue += rekey.Substring(i - 1, 1);

            }

 

            return readablevalue;

        }

 

    }

}

 

 

 

 

 

 

{.1}                         fff-ss-MM-dd-hh-mm-yyyy

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions

No comments:

Post a Comment

THANK YOU FOR COMMENT ON HTTP://TWEEKNTRICK.blogspot.com