471,831 Members | 1,253 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,831 software developers and data experts.

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 3539
Banfa
9,065 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 YellowAndGreen | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.