Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Code Snippet to convert

Featured Replies

Posted

Edited by yano65bis

  • Author

Hello

Please there is anyone who can translate for me a code writen in Vb.net and csharp to c++ (or even to Vb 6 or even to vb net !! as i did not come to solve it) and make the that code work.in fact this code snippet is a keygen code procdedure :

take a name in editBoxtext1 and put it in VAR Nom and pass it to to Serial subRoutine and the result is a serial is desplayed in editBox2text

that is all , so simple ..

The result would be :

nom : yano

serial: 463375942

--code snippet----vb net ??

Public Function A0(ByVal nom As String) As Integer

nom = nom.ToUpper

Dim num As Integer = 0

Dim i As Integer

For i = 0 To nom.Length - 1

num = (num + (nom.Chars(i) * nom.Chars(i)))

Next i

num = ((num * num) * num)

Return (Math.Abs(CInt((num - (num Mod &H7D6)))) + &H7BA)

End Function

--code snippet----csharp ??

public int A0(string nom)

{

nom = nom.ToUpper();

int num = 0;

for (int i = 0; i < nom.Length; i++)

{

num += nom * nom;

}

num = (num * num) * num;

return (Math.Abs((int) (num - (num % 0x7d6))) + 0x7ba);

}

Thanks

yano

Something like this should work in C++

#include <Windows.h>
#include <algorithm>
#include <math.h>
#include <string>int A0( const std::string& str )
{
std::string upp = str;
std::transform( upp.begin(), upp.end(), upp.begin(), ::toupper ); int nReturn = 0;
const char* pszString = upp.c_str();
for( unsigned int x = 0; x < upp.size(); x++ )
{
nReturn += pszString[x] * pszString[x];
} nReturn = ( nReturn * nReturn ) * nReturn;
return ( abs( (int)( nReturn - ( nReturn % 0x7D6 ) ) ) + 0x7BA );
}int __cdecl main( int argc, TCHAR* argv[] )
{
std::string str( "This is a string to test." ); int nTest = A0( str ); return 0;
}

Edited by atom0s

  • Author

Hi

I thank you so much lol.I will try that code and inform you of its working.

Newbie :)

Thanks

  • Author

Hello Atom0s

It works well ,thanks

Newbie yano :victory::)

  • Author

Hello Atoms

I tryed to translate another Snippet with a slight difference en serial routine but did nort work : ERROR : DIVISION BY ZERO !!

I paste here the code in csharp (from Reflector) :

public static long m000219(string p0)

{

p0 = p0.ToUpper();

long num = 0L;

for (int i = 0; i < p0.Length; i++)

{

num += p0 * p0;

}

num = ((num * num) * num) % ((long) Math.Pow(2.0, 32.0));

num -= (long) Math.Pow(2.0, 32.0);

if (num < ((long) (-Math.Pow(2.0, 32.0) / 2.0)))

{

num += (long) Math.Pow(2.0, 32.0);

}

return (Math.Abs((long) (num - (num % 0x837L))) + 0x16f7L);

}

--Translated en c++ but fail :Edivbyzero exeption :

#include <algorithm>

#include <math.h>

#include <string>

long serial( const std::string& str )

{

std::string upp = str;

std::transform( upp.begin(), upp.end(), upp.begin(), ::toupper );

long nReturn = 0L;

const char* pszString = upp.c_str();

for( unsigned int x = 0; x < upp.size(); x++ )

{

nReturn += pszString[x] * pszString[x];

}

nReturn = (( nReturn * nReturn ) * nReturn) % ((long)pow(2.0,32.0));

nReturn -= (long)pow(2.0, 32.0);

if (nReturn < ((long) (-pow(2.0, 32.0) / 2.0)))

{

nReturn += (long)pow(2.0, 32.0);

}

return (abs((long) (nReturn - (nReturn % 0x837L))) + 0x16f7L);

}

//

int __cdecl main( int argc, TCHAR* argv[] )

{

std::string str( "This is a string to test." );

long nTest = serial( str );

return 0;

}

thanks for reply


char *strtoupper(char *p)
{
char *s=p;
while( *s )
{
*s=toupper((unsigned char) *s);
++s;
}
return p;
}
long long m000219(char* text)
{
int len = strlen(text);
int i = 0;
long long num = 0;
long long x = pow(2.0,32.0); text = strtoupper(text);
for (i = 0 ; i<=len; i++)
{
num += text[i] * text[i];
}
num = (num * num * num) % x;
num -= x; if (num < ((-x) >> 1))
{
num += x;
}
num = ((~num) - ((~num) % 0x837) + 0x16f7); return num;
}

hope it helps

Edited by sama

Following my similar method with the STL:


#include <Windows.h>
#include <algorithm>
#include <string>
#include <math.h>static long m000219( const std::string& str )
{
std::string upp = str;
std::transform( upp.begin(), upp.end(), upp.begin(), ::toupper ); long num = 0L;
const char* pszString = upp.c_str(); for (long i = 0; i < upp.size(); i++)
{
num += pszString[i] * pszString[i];
} num = (( num * num ) * num) % ( (long)pow( 2.0f, 32.0f ) );
num -= (long)( pow( 2.0f, 32.0f ) ); if (num < ( (long)-pow( 2.0f, 32.0f ) / 2.0f ) )
{
num += (long)( pow( 2.0f, 32.0f ) );
} return ( abs( (long)( num - ( num % 0x837L ) ) ) + 0x16F7L );
}int __cdecl main( int argc, TCHAR* argv[] )
{
std::string str( "This is a string to test." );
long nTest = m000219( str ); return 0;
}

Grr stupid forum formatting sucks lol..

Edited by atom0s

  • Author

Hi SAMA

The code works fine but sometimes when changing the string the result is a negative number ! so i changed the code :

num = ((~num) - ((~num) % 0x837) + 0x16f7);

To : num= (abs((long long)( num - ( num % 0x837 ) )) + 0x16f7 ); // and works 100%

Thanks Same

Newbie yano

  • Author

Hi atom0s

The code does not work :

stepping the line code : num = (( num * num ) * num) % ( (long)pow( 2.0f, 32.0f ) );

a message of error : Idivbyzero exception is desplayed.

please helpme to solve it.

Thanks for you reply and your help :).

thanks

Newbie yano

Edited by yano65bis

It's because in C# long is 64bit integer but in C++ it's 32bits. Use "long long" instead.

  • Author

Thanks Kao for the trick.I will try to change it.

Newbie yano :)

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.