Click here to Skip to main content
14,327,936 members
Rate this:
Please Sign up or sign in to vote.
See more:
I'm creating SMS application for notify users about important activities. but the problem is there is no way to track for reply messages for relevant sms. I'm sending and receiving SMS from same number.
What i thought was generate 4 Character string and sending with the message like

<SMS message><space><GeneratedKey>

When user send reply with that generated Key value

<GeneratedKey><space><SMS message>

Using that key value I can find the reply messages for given SMS.

Since that key is need to be easy to enter I thought to generate sequence from both digits and characters and key length is 4.

each character sequence goes like.


generated keys should be like below.

0000<br />
0001<br />
0002<br />
...<br />
...<br />
0009<br />
000A<br />
000B<br />
....<br />
000Z<br />
0010<br />

Before sending SMS i'm going to add record to table with next key and after that I'm sending message with that key value.

Experts please give your thoughts on this approach and also can you please help me to generate next key value from c#?
krumia 2-Jul-12 6:44am
Hi Damith,
Generating keys from a sequence could be a bad idea. Because the sequence can be used for spoofing. (See You may want to consider sending a random number as a key.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

This is what I implemented

String chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";

private static String Increment(String s)
    if (string.IsNullOrEmpty(s))
        return string.Empty;

    char lastChar = s[s.Length - 1];
    string fragment = s.Substring(0, s.Length - 1);

    if (chars.IndexOf(lastChar) < 35)
        lastChar = chars[chars.IndexOf(lastChar) + 1];
        return fragment + lastChar;

    return Increment(fragment) + '0';

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100