Hi Shamboo,
I think you want to get 25 characters from the string, string may have 25 more or less characters.. If I am right, you can try this
So here is what I have tried, which might be useful and keep it as refernce
string encodeStr = @"!#$%&'()*+,-./0123456789:;<=>? @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~";
string decodeStr = @"@ABCDEFGHIJKLMNO0123456789:;<=>? pqrstuvwxyz{|}~!#$%&'()*+,-./`abcdefghijklmnoPQRSTUVWXYZ[\]^_";
protected void Page_Load(object sender, EventArgs e)
{
string schoolName = "RMHSSchool";
string schoolAddress = "MaduraiSchool";
string regId = "101";
string versionNum = "1.0";
string softwareType = "ASP";
string finalCipherText = string.Empty;
string finalRawText = string.Empty;
finalCipherText = encodeString(schoolName.Substring(0, 8)) + encodeString(schoolAddress.Substring(0, 8))+ encodeString(regId.Substring(0, 3)) + encodeString(versionNum.Substring(0, 3)) + encodeString(softwareType.Substring(0, 3));
finalRawText = decodeString(schoolName.Substring(0, 8)) + decodeString(schoolAddress.Substring(0, 8)) + decodeString(regId.Substring(0, 3)) + decodeString(versionNum.Substring(0, 3)) + decodeString(softwareType.Substring(0, 3));
string compareFinal = schoolName.Substring(0, 8) + schoolAddress.Substring(0, 8) + regId.Substring(0, 3) +
versionNum.Substring(0, 3) + softwareType.Substring(0, 3);
if (decodeString(finalCipherText) == compareFinal)
{
}
else
{
}
}
protected string encodeString(string rawText)
{
string cipherText = string.Empty;
foreach (char rawChar in rawText)
{
cipherText += encodeStr.ElementAt(decodeStr.IndexOf(rawChar));
}
return cipherText;
}
protected string decodeString(string cipherText)
{
string rawText = string.Empty;
foreach (char cipherChar in cipherText)
{
rawText += decodeStr.ElementAt(encodeStr.IndexOf(cipherChar));
}
return rawText;
}
You need to take care of validating the length of every string and other sort of validations.
Finally you will get 25 characters unique ID as per your requirement.
The above code is only for reference dont rely on it, customize the way you want and make it more secure.
Hope this helps you better
Regards,
RK