hi i am generating random password. but i want to get phonetic string of the password. Any idea how can i get phonetic string? example :
deT3f9y => delta - echo -Tango - number 3 - fox - number 9 - yankee
hi i am generating random password. but i want to get phonetic string of the password. Any idea how can i get phonetic string? example :
deT3f9y => delta - echo -Tango - number 3 - fox - number 9 - yankee
Have a lookup table that translates the characters into words ('a' -> "alpha") and then iterate over the characters in the generated password, looking up the word.
i have created class to generate phonetic string as below.
USAGE:
string Psw = "deT3f9y"
string Phone = Phonetic.GetPhoneticPassword(Psw);
enter code here
using System; using System.Collections.Generic; using System.Linq; using System.Web;
/// /// Summary description for Phonetic /// public class Phonetic { public Phonetic() { // // TODO: Add constructor logic here // }
public static string GetPhoneticPassword(string Passsord)
{
string PhoneticString = string.Empty;
char[] pswChar = Passsord.ToCharArray();
foreach (char chr in pswChar)
{
if (PhoneticString == string.Empty)
{
PhoneticString = GetPhoneticSting(chr);
}
else
{
PhoneticString += " - " + GetPhoneticSting(chr);
}
}
return PhoneticString;
}
public static string GetPhoneticSting(char Chr)
{
string PhString= string.Empty;
string Newchar = Chr.ToString();
switch (Newchar.ToLower())
{
case "a":
PhString = "alpfa";
break;
case "b":
PhString = "bravo";
break;
case "c":
PhString = "charlie";
break;
case "d":
PhString = "delta";
break;
case "e":
PhString = "echo";
break;
case "f":
PhString = "foxtrot";
break;
case "g":
PhString = "golf";
break;
case "h":
PhString = "hotel";
break;
case "i":
PhString = "item";
break;
case "j":
PhString = "juliet";
break;
case "k":
PhString = "kilo";
break;
case "l":
PhString = "lima";
break;
case "m":
PhString = "mike";
break;
case "n":
PhString = "november";
break;
case "o":
PhString = "oscar";
break;
case "p":
PhString = "papa";
break;
case "q":
PhString = "queen";
break;
case "r":
PhString = "romeo";
break;
case "s":
PhString = "sugar";
break;
case "t":
PhString = "tango";
break;
case "u":
PhString = "uniform";
break;
case "v":
PhString = "victor";
break;
case "w":
PhString = "whiskey";
break;
case "x":
PhString = "x-ray";
break;
case "y":
PhString = "yankee";
break;
case "z":
PhString = "zulu";
break;
case "1":
PhString = "One";
break;
case "2":
PhString = "Two";
break;
case "3":
PhString = "Three";
break;
case "4":
PhString = "Four";
break;
case "5":
PhString = "Five";
break;
case "6":
PhString = "Six";
break;
case "7":
PhString = "Seven";
break;
case "8":
PhString = "Eight";
break;
case "9":
PhString = "Nine";
break;
case "0":
PhString = "Zero";
break;
default:
break;
}
if(CheckUpper(Chr.ToString()))
{
PhString = PhString.ToUpper();
}
return PhString;
}
public static bool CheckUpper(string strCheck)
{
if(string.Compare(strCheck,strCheck.ToUpper())==0)
{
return true;
}
else
{
return false;
}
}
}