468,484 Members | 1,761 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,484 developers. It's quick & easy.

How to create a string of alphanumeric values???

2
Hi all,

I want to create a string of alphanumeric values. Actually it is for security purpose. I am using C++ and I want the fuction for that...

Can anybody help regarding this?? Plzzzzzzzzzzz

Best Regards,
Symbee
Sep 23 '06 #1
3 3405
Banfa
9,055 Expert Mod 8TB
Use srand and rand to get random values in the range 0 - 61 (62 values)

Convert these to uppercase letters, lowercase letters and digits.

Expand|Select|Wrap|Line Numbers
  1. if (value < 26)
  2. {
  3.     outputCharacter = 'A' + value;
  4. }
  5. ...
  6.  
Strcitly speaking this isn't portable but it will work if you computer uses the ASCII character set.
Sep 23 '06 #2
symbee
2
Thanx for ur reply..

I want string like this 4gh5js83gk6l0s...what is the exact code to do this??

Plz help

Regards,
symbee
Sep 26 '06 #3
D_C
293 100+
Expand|Select|Wrap|Line Numbers
  1. for each character in the string
  2. {
  3.    /*int*/ random = (10+26)*rand();
  4.    if(random < 10)
  5.      random += '0';
  6.    else
  7.      random += 'a';
  8.    string += (char)random;
  9. }
Sep 27 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by shapper | last post: by
reply views Thread by ghjk | last post: by
reply views Thread by NPC403 | last post: by
reply views Thread by theflame83 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.