By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,826 Members | 2,443 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,826 IT Pros & Developers. It's quick & easy.

How to create a string of alphanumeric values???

P: 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
Share this Question
Share on Google+
3 Replies


Banfa
Expert Mod 5K+
P: 8,916
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

P: 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

100+
P: 293
D_C
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.