Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
4.25/5 (3 votes)
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.

0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ

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#?
Posted
Comments
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 http://en.wikipedia.org/wiki/Spoofing_attack). You may want to consider sending a random number as a key.

1 solution

This is what I implemented

C#
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';
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900