I have a vb.net function (in attachment) and I would like to have it in C++.
Does any expert could translate it or help me doing it? My C++ knowledge is very weak.
The function is to be putted in a DLL and called by Delphi.
Delphi calls the DLL like this: PEncripta = Function (Valor : Integer): PChar ; cdecl;
Public Function Encrypt(ByVal EncInteger As Integer) As Integer
Dim strReturn As String = String.Empty
Dim cipherText As String = String.Empty
Dim strSenha As String
strSenha = EncInteger
Dim nLetra As String
Dim L As Integer
strSenha = (strSenha)
For L = 1 To Len(strSenha)
nLetra = Asc(Mid(strSenha, L, 1))
nLetra = Chr(Trim(Str(Val(nLetra) Xor (L * 2))))
cipherText = cipherText & nLetra
strReturn = cipherText
Catch ex As Exception
strReturn = Nothing