【问题标题】:How to use getBytes() in VC++ [closed]如何在 VC++ 中使用 getBytes() [关闭]
【发布时间】:2013-12-20 19:42:34
【问题描述】:

如何在VC++中使用GetBytes()方法

在 Java 中,

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

输出:

 SaltedPassword :[B@3eca90

这里 saltedPassword 以 我想在 VC++ 中实现的相同方式获取 编码值

请任何人给我一个解决方案。

提前致谢..

【问题讨论】:

  • 如果您需要帮助,请发布您尝试过的内容并提出问题。我们不做“解决方案”,那是一份工作,而对于一份工作,我想要得到报酬。
  • "[B@3eca90" 看起来像是Object.toString() 调用的结果;它不是编码值。参见例如this。您可能想要对字节数组进行十六进制或 Base64 编码。

标签: c++ visual-c++ mfc cryptography encode


【解决方案1】:

使用 MFC 的可能解决方案如下:

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

但也许你应该先学习 MFC 和/或 C++

【讨论】:

    猜你喜欢
    • 2010-11-22
    • 2020-04-08
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 1970-01-01
    • 2021-08-03
    • 2011-05-28
    相关资源
    最近更新 更多