Answer the question
In order to leave comments, you need to log in
Implementing CR4 in C#?
solved encryption using the RC4 algorithm, found this post
and took the code from there.
this is how I pass data to the code:
byte[] pass = ASCIIEncoding.Unicode.GetBytes(TBpass.Text);
RC4 encoder = new RC4(pass);
string textCrypt = TBtext.Text;
byte[] ByteCrypt = ASCIIEncoding.Unicode.GetBytes(textCrypt);
byte[] result = encoder.Encode(ByteCrypt, ByteCrypt.Length);
string strout = UTF8Encoding.Unicode.GetString(result, 0, result.Length);
tbtext.text = strout;
text: 1111111111111111111111111111111111111111111111111111111111111111111111111111111
key: 123456
Conclusion: 藰 죻쿝 職郹萴 ⋛ 㤮 쒇 ǯ 남 남 ᥣ 퇙 58 楁 ꑅ ꑅ ṽ 띟 ䷺ 㾼 డ ⱄ ⱄ 垱兲 맯 ᧘ 无 ⣂ 站 䣆 ⒗ 鷺 뛲멵 㪀庢 굪 굪 䧕勃 䧕勃㧽倪퉵䀨忀㔮獐蝗돖ꍛⰗᘏႣ䭀䃊槟⟦⌈糔㇅樈㲰얋ഝ瞮㘧
when trying to decode, it gives the following
:
Answer the question
In order to leave comments, you need to log in
look at the lines.... in your code...
byte[] pass = ASCIIEncoding.Unicode.GetBytes(TBpass.Text);
RC4 encoder = new RC4(pass);
string textCrypt = TBtext.Text;
byte[] ByteCrypt = ASCIIEncoding.Unicode.GetBytes(textCrypt);
byte[] result = encoder.Encode(ByteCrypt, ByteCrypt.Length);
string strout = ASCIIEncoding.Unicode.GetString(result, 0, result.Length); // UTF8Encoding поменять на ASCIIEncoding
TBtext.Text = strout;
byte[] key = ASCIIEncoding.ASCII.GetBytes("Key");
RC4 encoder = new RC4(key);
string testString = "Plaintext";
byte[] testBytes = ASCIIEncoding.ASCII.GetBytes(testString);
byte[] result = encoder.Encode(testBytes, testBytes.Length);
RC4 decoder = new RC4(key);
byte[] decryptedBytes = decoder.Decode(result, result.Length);
string decryptedString = ASCIIEncoding.ASCII.GetString(decryptedBytes);
I did not test the code at the link you provided, but successfully implemented this algorithm using the code from the wiki - https://en.wikibooks.org/wiki/%D0%A0%D0%B5%D0%B0%D...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question