2 Aug 2013

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

20 comments:

  1. http://www.hackdonor.com/ ~ Learn Complete Hacking Tricks and Free Download Full Version Softwares.

    ReplyDelete
  2. I have been browsing online greater than three hours lately, yet I by no means found any interesting article like
    yours. It's lovely price sufficient for me. In my view, if all webmasters and bloggers
    made just right content as you probably did, the web might be a lot more
    useful than ever before.

    Feel free to surf to my web site: money making blogs

    ReplyDelete
  3. Fascinating blog! Is your theme custom made or did you download it from somewhere?

    A theme like yours with a few simple tweeks would really make my blog stand out.
    Please let me know where you got your theme. Appreciate it

    my weblog ... make free blog

    ReplyDelete
  4. I am genuinely glad to glance at this weblog posts which consists of plenty
    of helpful facts, thanks for providing these data.


    Check out my web site: make up blog

    ReplyDelete
  5. Great delivery. Sound arguments. Keep up the good work.


    Also visit my blog post :: small carpet cleaner

    ReplyDelete
  6. Hello to all, how is everything, I think
    every one is getting more from this web page, and your views are good in support of new
    viewers.

    Here is my homepage :: buy a house uk

    ReplyDelete
  7. We're a group of volunteers and opening a new scheme in our community.

    Your website offered us with valuable information to work on. You've done a
    formidable job and our entire community will be thankful to you.


    My webpage engines work

    ReplyDelete
  8. This is the right webpage for everyone who wants to understand this topic.
    You realize a whole lot its almost tough to argue with you (not
    that I really will need to…HaHa). You definitely put a new spin on a subject which has been discussed for ages.
    Great stuff, just great!

    Here is my website: various search

    ReplyDelete
  9. I got this web site from my buddy who shared with me concerning
    this web site aand now this time I am visiting this website annd reading very informative content at this time.


    Take a look at my web site; Las Vegas Kitchen Appliance Service

    ReplyDelete
  10. Excellent blog here! Also your site loads up very
    fast! What host are you using? Can I get your affiliate link to
    your host? I wish my website loaded up as fast
    as yours lol

    Also visit my web blog; top blogging sites

    ReplyDelete
  11. Nice post. I was checking continuously this blog and I'm
    impressed! Very helpful information specially the last section :) I handle such information a lot.
    I used to be looking for this particular information for
    a very lengthy time. Thank you and best of luck.

    My weblog :: jeux black jack estrie

    ReplyDelete
  12. I have been browsing on-line greater than three hours today,
    yet I by no means found any attention-grabbing article like yours.
    It's lovely price enough for me. In my view, if all site owners and bloggers made
    just right content as you probably did, the net will likely be a lot more useful than ever
    before.

    Also visit my web site :: déménageurs

    ReplyDelete
  13. When someone writes an article he/she keeps the idea of a user in his/her mind that how a user can be aware of it.
    Therefore that's why this article is perfect. Thanks!



    Feel free to surf to my homepage; online blogging

    ReplyDelete
  14. great post, very informative. I wonder why the other experts
    of this sector do not notice this. You must continue your writing.
    I am confident, you have a great readers' base already!


    Here is my homepage - otakv.Tumblr.com

    ReplyDelete
  15. I think everything typed made a great deal of
    sense. However, think on this, what if you typed a catchier post title?

    I ain't suggesting your information isn't good., but suppose
    you added a post title to maybe get people's attention? I mean "Security token Key Generagor in C#" is kinda vanilla.
    You could glance at Yahoo's front page and see how they write article titles to grab
    people to click. You might add a video or a related pic or two to
    get people excited about everything've written. Just my opinion,
    it might bring your posts a little bit more interesting.


    Also visit my homepage ... Telephone Demenagement Martin

    ReplyDelete
  16. I have read so many articles on the topic of the blogger lovers but this paragraph is genuinely
    a good post, keep it up.

    Also visit my homepage ... The Easy French

    ReplyDelete
  17. Great article! We are linking to this great content on our
    site. Keep up the good writing.

    My webpage - cie Demenagement Martin

    ReplyDelete
  18. This is very interesting, You are a very skilled blogger.
    I have joined your feed and look forward to seeking more of your magnificent post.
    Also, I've shared your site in my social networks!


    My page; seo copywriting

    ReplyDelete
  19. I am curious to find out what blog platform you have been working with?
    I'm experiencing some minor security issues with my latest blog and I would like to find something
    more safeguarded. Do you have any recommendations?


    Also visit my web-site - Demenagement Martin Sherbrooke

    ReplyDelete
  20. I truly love your website.. Very nice colors & theme. Did you make this website yourself?
    Please reply back as I'm trying to create my own site and want to find out where you got this
    from or just what the theme is called. Many thanks!


    Here is my website - best reiki business

    ReplyDelete