 |
 |
hi how can i find type of hash
|208|230|210|115|202 = admin
this is comersus_backoffice password crypted how i can decrypt it
|
|
|
|
 |
Simone,
A: I tried yours and used a key and clear text to encrypt and then decrypt. I get the same clear text.
B: I downloaded another rc4 algorithm and used the same key and clear text. That works fine.
When I put the encrypted text from your (A) into the decryption of (B) the clear text is different. Likewise if I put the encrypted text from (B) into (A) the clear text is different.
If both bits of code are supposedly RC4 compliant would you agree that providing I use the same key and clear text (which I did) I should get the same output for the encrypted and decrypted text?
I don't know then if there's more than one flavour of RC4 which is unlikely, or perhaps it's related to the key size or some other internal factor or perhaps one of the algorithms isn't telling the truth!
How would you verify which is right and which is wrong?
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
 |
I encountered this same problem, fixed by changing m_nBoxLen from 255 to 256 as mentioned in a post below.
|
|
|
|
 |
The problem I later found is that I believe the algorithm for RC4 has never been officially divulged and has been isolated by reverse engineering and other cryptanalysis techniques. The device I worked on uses RC4 and after finding one implementation of several did I find one that was compatible. The other three I tried all "failed" even though they worked "correctly". Why they don't officially release the algorithm is puzzling. After all, it's not, by all accounts, that secure anymore.
If there is one thing more dangerous than getting between a bear and her cubs it's getting between my wife and her chocolate.
|
|
|
|
 |
Awesome .
Thank you very much for this!
Cedric D.
|
|
|
|
 |
Hi. What does this line do?
RC4Engine.cs 82 output[offset] = (byte)((int)a^(int)b);
Appreciate the help. Thank you
|
|
|
|
 |
I was using this RC4 algorithm since years in my application.
It was working fine with .NET 1.1
But when I have converted my application to .NET 3.5, it was having problem decrypting the values.
I have debugged the code and observed that It was not able to decrypt the 2nd character always.
E.g. If I have encrypted the word "ABCDE", then while Decrypting the encrypted value, it is giving all the coorect values for A , C, D, E but not the 'B'.
It was returning some value like 'A��CDE'.
Any idea about this?
Please Help...!!!
|
|
|
|
 |
this is great. but how am i able to get this
currently having a project which needed this. but i cant seem to get this. someone pls tell me .thank you .
[email protected]
if u can e mail me it will be faster
|
|
|
|
 |
Hello,
I am a developer working for a commercial software company. I am interested in adapting source code found in this article. Can you tell me if there are license or copyright terms with which I must comply?
RC4 Encryption Algorithm: C# Version
Thanks for much for your help.
J Wilson
|
|
|
|
 |
Feel free do to it.
Ciao,
Simone
|
|
|
|
 |
Here is another implementation:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
namespace RC4
{
public class RC4
{
private byte[] K;
private byte[] S;
public byte[] State
{
get { return this.S; }
}
public RC4(string key)
{
this.K = StringToByteArray(key);
}
public RC4(byte[] key)
{
this.K = key;
}
public void KeySchedule()
{
this.S = new byte[this.K.Length];
for (int i = 0; i < this.S.Length; i++)
{
this.S[i] = (byte)i;
}
int j = 0;
for (int i = 0; i < this.S.Length; i++)
{
j = (j + this.K[i % K.Length] + this.S[i]) % this.S.Length;
this.Swap(i, j);
}
}
private int i = 0;
private int j = 0;
public byte Loop()
{
i = (i + 1) % this.S.Length;
j = (j + S[i]) % this.S.Length;
System.Windows.Forms.MessageBox.Show(j + "");
this.Swap(i, j);
byte z = this.S[(this.S[i] + this.S[j]) % this.S.Length];
return z;
}
public byte Encrypt(byte input)
{
return (byte)(this.Loop() ^ input);
}
private void Swap(int i, int j)
{
byte tmp = this.S[i];
this.S[i] = this.S[j];
this.S[j] = tmp;
}
private static byte[] StringToByteArray(string input)
{
ASCIIEncoding encoding = new ASCIIEncoding();
return encoding.GetBytes(input);
}
}
}
|
|
|
|
 |
very interesting.
did you can post a little snipet code on how to use it, please.
thanks in advance!
|
|
|
|
 |
I need the c# code for making key generation , encryption and decryption in RSA algorithm
|
|
|
|
 |
// original from sf under GNU LESSER GENERAL PUBLIC LICENSE // http://sourceforge.net/projects/rc4dotnet // simplified by me and fixed for files using System; using System.IO; using System.Text;
namespace Encryption.LESR_RC4_Geffe { public interface ICoder { void Encrypt(string password, string file, string targetFile); void Decrypt(string password, string file, string targetFile); } public class RC4: ICoder { private const int EncodingCode = 1251; public void Encrypt(string password, string file, string targetFile) { byte[] content = encrypt(password, File.ReadAllBytes(file)); File.WriteAllBytes(targetFile, content); }
public void Decrypt(string password, string file, string targetFile) { byte[] content = encrypt(password, File.ReadAllBytes(file)); File.WriteAllBytes(targetFile, content); }
private int getAsciiCode(char character) { return (int)(Encoding.GetEncoding(EncodingCode).GetBytes(character + "")[0]); }
private char fromAsciiCode(int asciiCode) { byte[] bytes = new byte[1]; bytes[0] = (byte)asciiCode; return Encoding.GetEncoding(EncodingCode).GetString(bytes)[0]; }
private string hexToBinary(string packtype, string datastring) { int i, j, datalength, packsize; byte[] bytes; char[] hex; string tmp;
datalength = datastring.Length; packsize = (datalength/2) + (datalength % 2); bytes = new byte[packsize]; hex = new char[2];
for (i = j = 0; i < datalength; i+=2) { hex[0] = datastring[i]; if (datalength - i == 1) hex[1] = '0'; else hex[1] = datastring[i + 1]; tmp = new string(hex, 0, 2); try { bytes[j++] = byte.Parse(tmp, System.Globalization.NumberStyles.HexNumber); } catch {} /* grin */ } return Encoding.GetEncoding(EncodingCode).GetString(bytes); }
public string binaryToHex(string bindata) { int i; byte[] bytes = Encoding.GetEncoding(EncodingCode).GetBytes(bindata); string hexString = ""; for (i = 0; i < bytes.Length; i++) { hexString += bytes[i].ToString("x2"); } return hexString; }
private byte[] encrypt(string password, byte[] data) { int a, i, j, k, tmp, pwd_length, data_length; int[] key, box; byte[] cipheredText;
password = hexToBinary("H*", password); // valid input, please! pwd_length = password.Length; data_length = data.Length; key = new int[256]; box = new int[256]; cipheredText = new byte[data.Length];
for (i = 0; i < 256; i++) { key[i] = getAsciiCode(password[i % pwd_length]); box[i] = i; } for (j = i = 0; i < 256; i++) { j = (j + box[i] + key[i]) % 256; tmp = box[i]; box[i] = box[j]; box[j] = tmp; } for (a = j = i = 0; i < data_length; i++) { a = (a + 1) % 256; j = (j + box[a]) % 256; tmp = box[a]; box[a] = box[j]; box[j] = tmp; k = box[((box[a] + box[j]) % 256)]; cipheredText[i] = (byte)(data[i] ^ k); } return cipheredText; } } }
|
|
|
|
 |
And even simpler - with all language symbols
namespace Encryption.LESR_RC4_Geffe { public class RC4: ICoder { private const int EncodingCode = 1251; public void Encrypt(string password, string file, string targetFile) { byte[] passwordToPass = System.Text.Encoding.Default.GetBytes(password); byte[] content = encrypt(passwordToPass, File.ReadAllBytes(file)); File.WriteAllBytes(targetFile, content); }
public void Decrypt(string password, string file, string targetFile) { Encrypt(password, file, targetFile); }
private byte[] encrypt(byte[] password, byte[] data) { int a, i, j, k, tmp, pwd_length, data_length; int[] key, sbox; byte[] cipheredData;
pwd_length = password.Length; data_length = data.Length; key = new int[256]; sbox = new int[256]; cipheredData = new byte[data.Length];
for (i = 0; i < 256; i++) { key[i] = password[i % pwd_length]; sbox[i] = i; } for (j = i = 0; i < 256; i++) { j = (j + sbox[i] + key[i]) % 256; tmp = sbox[i]; sbox[i] = sbox[j]; sbox[j] = tmp; } for (a = j = i = 0; i < data_length; i++) { a = (a + 1) % 256; j = (j + sbox[a]) % 256; //swap tmp = sbox[a]; sbox[a] = sbox[j]; sbox[j] = tmp; k = sbox[((sbox[a] + sbox[j]) % 256)]; cipheredData[i] = (byte)(data[i] ^ k); } return cipheredData; } } }
|
|
|
|
 |
Thanks Simone for this article, but actually I have a comment about the algorithm implementation,
you are using 'mod 255', while I've read the algorithm before & it says to use 'mod 256'
that differs in the output completely, so do you have any explanation for wt you've done or that was a mistake?
Thanks,
|
|
|
|
 |
I agree, I think line 266 of RC4Engine.cs should be:
static public long m_nBoxLen = 256;
|
|
|
|
 |
hello.....i`m now doing my final year project in my university.....and i have to do the encryption and decryption via the PIC microcontroller....could anyone help me how could i do my project or any references or tutorial.....I`m gonna do it in C language programming.......
|
|
|
|
 |
Hello,
This code doesn't seem to encrypt/decrypt the unicode (chinese/japanese) characters correctly. Is there anything that needs to be modified in order to make that work ?
Thanks in advance.
|
|
|
|
 |
This algorithm does not produce correct outputs. Should not be used. Instead another .NET library http://rc4dotnet.devhome.org
|
|
|
|
 |
Can you explain me why???
Thanks in Advance
|
|
|
|
 |
Change this line of code, I think it will work.
static public long m_nBoxLen = 256;
|
|
|
|
 |
Thanks man!
Your example was exactly what I was looking for. A small and simple (and working) encryption class for a small and simple tool that needs to hide a password in its settings file. All the other examples I've found using Microsoft's encryption API were just too complicated for a beginner. You've really made my day!
Cheers
Christian
|
|
|
|
 |
I can't encript the following frase
Estos fabio ay dolor que ves ahora campos de soledad mustio collado fueron otrora
When you encrypt it it loses part of the message and when you decipher you got only
Estos fabio ay
By
Orestes
|
|
|
|
 |
AntoninoLuis wrote: When you encrypt it it loses part of the message and when you decipher you got only
It's a bug of the interface: it doesn't display all the crypted phrase. The encryption class works fine : if you want to test it you have to debug the project and set breakpoint to line 314/315 of frmFrontend.cs.
Hope it heps.
Simone
|
|
|
|
 |
I don't know much about encryption, but I found it really easy to add your class to my Delphi .NET project and encrypt some data. Good work. Thank you
|
|
|
|
 |
Which is faster RSA, ECC, DES, or RC4? I know symmetric enc. is faster so I think it's RC4, but wanted to double check.
Can RC4 be used in either CBC or ECB mode?
Can RC4 be us as a public key algorithm?
thanks!
|
|
|
|
 |
That's a pretty dumb question. Google the internet for answers before asking something like this.
ROFLOLMFAO
|
|
|
|
|
 |
Find a way to get it. Don't beg for it.
ROFLOLMFAO
|
|
|
|
 |
Can u please tell me how it can be done using this algorithm
Please pass me refrence if u have anything.
shekhar
|
|
|
|
 |
The RC4 algorithm works very well, but I need to hold the text in a file and then load it and descrypt it. What kind of file I need for that ?
I tried using a simple StreamFile in C#, but when I load the text again, and try to descrypt it, the result isn't the first text typed by myselft(I think the troubles are due to the encryption characters).
What I can do ?
Thanks.
Ruben
|
|
|
|
|
 |
Hi
I've just completed writing a little encryption program that allows you to load text into a text control, encrypt it and save it again. I wrote the original in WINAPI C and found the problem you mentioned when I translated it into CSharp. I found that the 'Line ' methods of the StreamReader, StreamWriter and TextBox classes added carriage return characters ('\r\n') to terminate the lines. The way round this is to read the whole stream from a text file into a single string using the ReadToEnd method. Store the string as a buffer and load it into the the textbox with Text and not Lines even though it is multiline. You can change the text and refresh the buffer with the modified text. Process the buffer with RC4 and store the result again as a string in the buffer. Display and save from the buffer - don't display and then take the text from the display for storing as Windows alters it in mysterious ways. Save the string using the Write method and it should work. Hope that helps.
Ti
ps I used a modified version of a C function for the RC4 engine. You can find it on
www.cr0.net:8040/code/crypto/rc4/
Ti
|
|
|
|
 |
Hey, I was just reading over your post, and I seen that you have found a solution to the saving and loading files problems. I was wondering if you had your source code posted anywhere online. Your help would be greatly appreciated.
|
|
|
|
 |
I had the same problem and I've managed to solve them.
I've created ClassExtensions.cs with a function (for my purposes):
public static string LoadFromFile(string fileName)
{
using (StreamReader streamReader = new StreamReader(fileName))
{
return streamReader.ReadToEnd();
}
}
and class Encryption with a facade to RC4 encryption class:
public class Encryption
{
public static string Rc4Encrypt(string input)
{
RC4Engine enc = new RC4Engine();
enc.EncryptionKey = "Key";
enc.InClearText = input;
enc.Encrypt();
return enc.CryptedText;
}
public static string Rc4Decrypt(string input)
{
RC4Engine enc = new RC4Engine();
enc.EncryptionKey = "Key";
enc.CryptedText = input;
enc.Decrypt();
return enc.InClearText;
}
To load and decrypt:
string StringToLoadAndDecode = Encryption.Rc4Decrypt(ClassExtensions.LoadFromFile(fileName));
To encrypt and save:
using (StreamWriter streamWriter = new StreamWriter(fileName, false))
{
streamWriter.Write(stringToEncodeAndSave);
streamWriter.Close();
}
I had to simplify this code so I'm not sure if would work perfectly, but it presents the idea.
Regards
|
|
|
|
 |
In RC4Engine.cs Line 266
is defined: static public long m_nBoxLen = 255;
its not correct!
correct is:
static public long m_nBoxLen = 256;
// DesignFehler! 0x0 ... 0xff entspricht 256
// [email protected] 22.01.2005
|
|
|
|
 |
We saw your coding(c# version).We are doing our final project(B.E-CSE) in WEP.It will be more helpful to us if u send us the original code(C version) of RC4 algorithm and its explanation for our reference.We assure that we will not misuse the code in anyway.
Thank you
|
|
|
|
 |
I had a question about the size of the encrypted string that is created. In running the windows program, the cipering and deciphering work as advertized; however, when I deploy the ciphered string to a field in a database, I nottice that whenI attempt to log in and decipher the ciphered password, I get a failure. Thisa happens when the cleartext password exceeds 6 characters. Could it be that the ciphered copde is in utf format and that there is not a simple 1-to-1 correspondance between the clear text and the ciphered code? Is is getting truncated? I noticed that when I select * from the database, the next field is offset, in other words the column reporting format is pushed to the right.
Sincerely
Connie Irwin
|
|
|
|
 |
even though it's a bit simple it's a cool program and and has really helped me to understand encryption.
thanks for it!
|
|
|
|
 |
you're wellcome!
Simone
|
|
|
|
 |
you're wellcome
Simone
|
|
|
|
|
 |
Thank you for the notification.
The web site http://www.mentalis.org/soft/projects/crypto/ is very nice.
I wanted only to do a didactic article.
Bye,
Simone
|
|
|
|
 |
It is nice to see the algorithm in C#, however .NET already has a strong, thought native wrapper of good algorithm like http://csrc.nist.gov/CryptoToolkit/aes/rijndael/
It would habe been better if you had derived your class from System.Security.Cryptography.SymmetricAlgorithm
Also do not spend time creating keys from the user string in the RC4 code. Your method is not verified and can be week. Init the engine with byte arrays and leave it up to the user to find a proper way to convert strings to byte keys.
Hope you have time to do this for RC4 and other algorithms . There seem to be more info for other encryption algorithms at http://www.eskimo.com/~weidai/scan-mirror/cs.html
I would like to see some of them properly implemented in pure C#.
|
|
|
|
 |
Thank you very much for your suggestions.
I know both the native wrapper and the System.Security.Cryptography.SymmetricAlgorithm and I used them in my development project. That article should be only a starting point. It is only a demo project.
Bye,
Simone
|
|
|
|
 |
There is a ARCFOUR managed implementation, based on System.Security.Cryptography.SymmetricAlgorithm, available in Mono (http://www.go-mono.com/). It is part of the assembly Mono.Security.dll (with other security/cryptography) related classes.
Also all the .NET cryptographic algorithms (DSA, RSA, RC2, AES, DES and TripleDES) are available in managed versions (as part of Mono's corlib).
|
|
|
|
 |
Good to know.
Thanks for the info.
Simone
|
|
|
|
 |
Thanks for the info.
I found RC4 really there and some of the secure hashing algorithms implemented properly in C#, but Mono still seem to call CryptoAPI in some places for Win32 implementation (Mono.Security.Win32), as can be seen in Mono.Security.Cryptography.CryptoAPI
Further more I am not sure if they have re-writen any of System.Security.Cryptography classes found in corelib.dll, or they are from the original .NET implementation.
|
|
|
|
|