第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法將加密文本從 C# 傳遞到 C++ 和相反

無法將加密文本從 C# 傳遞到 C++ 和相反

C#
慕運維8079593 2021-06-03 18:09:43
我有一個包含 AES 加密的 c++ dll,該函數(shù)有兩個輸入:字符串:使用 AES 加密字符串:加密輸出這是外部函數(shù):extern "C" __declspec(dllexport) void aes_crypter(const char* string_in , wchar_t* string_out);void aes_crypter(const char* string_in , wchar_t* string_out){    std::string X_KEY = "abcdefghijklmnopqrstuvwxyz123412";    std::string X_PSS = "612345601234512";    //////// convert input text to LPCWSTR    const wchar_t* inputtext = convertCharArrayToLPCWSTR(string_in);    //////// convert LPCWSTR to string [const to string result wrong ]    std::wstring ws(inputtext);       std::string str(ws.begin(), ws.end());    //////// Encrypt    auto encr = encrypt(str, key, X_PSS);    //////// Convert and Return to Output String    std::wstring widestr = std::wstring(encr.begin(), encr.end());     const wchar_t* output_crypt = widestr.c_str(); /// CONVERT STD TO WCHAR    swprintf(string_out, 4096,output_crypt);}代碼工作正常,問題出在我的 C# 應(yīng)用程序中:這是導(dǎo)入功能代碼:[DllImport("simpleAES.dll",CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]private static extern void aes_crypter(string string_in, StringBuilder string_out);問題 :如果我將 CharSet 設(shè)置為 ANSI,輸入字符串工作正常,在 C++ 中返回正確但輸出字符串僅返回一個字符錯誤!如果我將 CharSet 設(shè)置為 UNICODE,則輸入字符串返回錯誤且只有一個字符。但是輸出字符串返回正確!我哪里出錯了?我該如何解決?
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 124 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號