I need an example of using the Chr()
function or something equivalent in C ++ Builder.
I need to do a function to decrypt the database password.
I need an example of using the Chr()
function or something equivalent in C ++ Builder.
I need to do a function to decrypt the database password.
C ++ is different from Delphi in this respect. The type char
in C ++ is both a numeric and text type. You can either store in a variable char
the textual representation of the character (with single quotation marks) or use a simple number (usually equivalent to a single byte). So conversion is not necessary. Save the number you would pass to the Chr()
function and you will already get the character you want. So:
char x = 65; //é o caractere A
See running on ideone .
Obviously where there is a literal number can be a variable or expression that results in this number.
If you want to use a multi-byte character, the most appropriate type is wchar_t
.
The result of the decryption function follows.
String DesprotegeSenhaSQL(String senha)
{
int i, j;
String aux, texto;
j=1;
for(i=1; i<=senha.Length();i++)
{
if (senha.SubString(i,1)!="-" && senha.SubString(i,1)!="#")
{
aux = aux+senha.SubString(i,1);
}
else
{
try {
texto=texto+char(StrToInt(aux)-j);
} catch(Exception &ex)
{
exit;
}
j=j+1;
aux="";
}
}
return texto;
}