XORメソッドを使用して暗号化/復号化を試みています。 これまでコンソールC++でこの作業を行ってきましたが、私はVC++を初めて使用しています。 暗号化は次のように動作します。Visual C++の奇妙なコンパイラエラー
key = 3
x = 5 // The item being encrypted
encryptedx = x^key // the "^" is XOR
だから今、私はこれがコンソールウィンドウことをよりよく見えるように、VC++でそれを作りたいです。 VC++のデザインビューでは、2つのリッチテキストボックス、キーの編集ボックス、およびプロセスを開始するためのいくつかのボタンがあります。 それは本当に簡単に聞こえるが、私はこれらのエラーを取得:
------ Build started: Project: Encryptor, Configuration: Debug Win32 ------
1> Encryptor.cpp
1>c:\users\**********c*********ncryptor\encryptor\Form1.h(264): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(707): could be 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(std::basic_string<_Elem,_Traits,_Ax> &&)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(762): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(767): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(772): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> while trying to match the argument list '(std::string, System::String ^)'
1>c:\*******gl\*****cryptor\encryptor\Form1.h(281): error C2679: binary '=' : no operator found which takes a right-hand operand of type 'System::String ^' (or there is no acceptable conversion)
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(707): could be 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(std::basic_string<_Elem,_Traits,_Ax> &&)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(762): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const std::basic_string<_Elem,_Traits,_Ax> &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(767): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(const _Elem *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xstring(772): or 'std::basic_string<_Elem,_Traits,_Ax> &std::basic_string<_Elem,_Traits,_Ax>::operator =(_Elem)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1> while trying to match the argument list '(std::string, System::String ^)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
そして、ここではコードです:
#include <string>
#include "crypFunc.cpp"
int key = 0;
char tempChar;
int stringLenght = 0;
string strBuffer = "";
using namespace std;
//
//
//
//
//
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
if(KeyBox->Text)
{
key =Convert::ToInt32(KeyBox->Text);
numericUpDown1->Value = key;
}
}
//
//
//
//
private: System::Void EncryptButton_Click(System::Object^ sender, System::EventArgs^ e)
{
EncryptedBox->Text = "";
strBuffer = DecryptedBox->Text;
stringLenght = strBuffer.size();
if(strBuffer.size() && key)
{
for(int i = 0; i < stringLenght; i++)
{
tempChar = encrypt(strBuffer[i], key);
EncryptedBox->Text = EncryptedBox->Text + tempChar;
}
}
}
private: System::Void DecryptButton_Click(System::Object^ sender, System::EventArgs^ e)
{
DecryptedBox->Text = "";
strBuffer = Convert::ToString(EncryptedBox->Text);
stringLenght = strBuffer.size();
if(strBuffer.size() && key)
{
for(int i = 0; i < stringLenght; i++)
{
tempChar = decrypt(strBuffer[i], key);
DecryptedBox->Text = DecryptedBox->Text + tempChar;
}
}
}
};
}
私は本当にあなたのいくつかはことを願って、私を助けたいです。
ちょっと。私はあなたの答えを理解し、私はソースコードでそれを設定しましたが、それでも動作しません。 System :: Void EncryptButton_Clickでこの問題を解決する方法を教えてください。 – Janman
それはあなたのために働いたのですか? 私はすべての時間を同じエラーを持っている:/ あなたの助け後のコードの ワンピース: のプライベート:システム::ボイドEncryptButton_Click(システム::オブジェクト^送信者、システム:: EventArgsの^ e)の \t \t { \t \t \t std :: string standString( ""); \t \t \t EncryptedBox->テキスト= gcnewストリング(standString.c_str()) \t \t \t \t \t \t stringLenght = systemString。サイズ(); \t \t \t があれば(!systemString = "" &&キー) \t \t \t {のため \t \t \tは(int型私= 0;私 Text = EncryptedBox-> Text + tempChar; ' –
Janman
私は仕事をしているので、ATMをテストできません。私たちはjavaを使用しています。私はそれが過去にこのようなエラーを修正する方法を考えていました。 私が家に帰ると少し深く掘ることができます。 – clamchoda