Diberdayakan oleh Blogger.

Security token Key Generagor in C#

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
Thank you for reading the article about Security token Key Generagor in C# on the blog NEW TECH If you want to disseminate this article on please list the link as the source, and if this article was helpful please bookmark this page in your web browser by pressing Ctrl + D on your keyboard keys.

New articles :

  • Disable T5120 RAID - Cause failure in booting/installing from HD
  • How To Reset The ALOM Password On A Sun Fire T2000
  • Broadband Error Codes
  • Error 651: How to Fix it in Windows 7/8
  • How to Set up a new PPPoE connection on your Windows 7
  • Installing Net-SNMP on Solaris OS
  • How to Upgrade to Perl 5.12.5 on Linux Machine
  • how to get process id attached with particular port in solaris
  • Year 2038 problem
  • Windows exchange Server 2007 installation Steps
  • Related articles :