-2

How to Use GetBytes() Method in VC++

In Java ,

         **byte[] saltedPassword = (password + getSalt()).getBytes();**

output :

 SaltedPassword :[B@3eca90

here saltedPassword get encoded value in the same way i want to implement in VC++

Please anyone give me a Solution.

Thanks in Advance..

Community
  • 1
  • 1
Karthick
  • 183
  • 3
  • 14
  • 4
    If you want help, post what you tried and ask a question. We don't do "solutions", that's a job and for a job, I'd want to be paid. – nvoigt Dec 04 '13 at 10:55
  • "\[B@3eca90" looks like the result of an `Object.toString()` call; it's not an encoded value. See e.g. [this](http://stackoverflow.com/questions/10904911/java-how-to-convert-int-array-to-string-with-tostring-method). You probably want to hex or Base64 encode the byte array. – ntoskrnl Dec 04 '13 at 18:36

1 Answers1

0

A possible solution using MFC goes like this:

CString getSalt()
{
  return (CString)"mysalt" ;  // dummy function, should be replaced by *your* code
}
...

CByteArray saltedPassword ;
CString password ;
...

CString saltedpasswordstring = password + getSalt() ;

for (int i = 0; i < saltedpasswordstring.GetLength() ; i++)
{
  saltedPassword.Add((BYTE)saltedpasswordstring[i]) ;
}

// now the saltedPassword array contains what you want

But maybe you should learn MFC and/or C++ before

Jabberwocky
  • 48,281
  • 17
  • 65
  • 115