Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static byte[] StringToByteArray(String hex)
- {
- int NumberChars = hex.Length;
- byte[] bytes = new byte[NumberChars / 2];
- for (int i = 0; i < NumberChars; i += 2)
- bytes[i / 2] = Convert.ToByte(hex.Substring(i, 2), 16);
- return bytes;
- }
- private void button3_Click(object sender, EventArgs e)
- {
- string featherearring = "00804804A02A1CA20100000000000000D2F8B6FABBB700000000000000000000";
- var strarray = StringToByteArray(featherearring);
- byte[] strarray_comp = Enc.Encrypt(strarray);
- string conv = BitConverter.ToString(strarray_comp);
- MessageBox.Show(conv.Replace("-", ""));
- }
- public static byte[] BitArrayToByteArray(BitArray bits)
- {
- byte[] bytes = new byte[bits.Length / 8];
- bits.CopyTo(bytes, 0);
- return bytes;
- }
- public static byte[] Encrypt(byte[] input)
- {
- BitArray source = new BitArray(input);
- BitArray target = new BitArray(source.Length);
- target[26] = source[0];
- target[31] = source[1];
- target[17] = source[2];
- target[10] = source[3];
- target[30] = source[4];
- target[16] = source[5];
- target[24] = source[6];
- target[2] = source[7];
- target[29] = source[8];
- target[8] = source[9];
- target[20] = source[10];
- target[15] = source[11];
- target[28] = source[12];
- target[11] = source[13];
- target[13] = source[14];
- target[4] = source[15];
- target[19] = source[16];
- target[23] = source[17];
- target[0] = source[18];
- target[12] = source[19];
- target[14] = source[20];
- target[27] = source[21];
- target[6] = source[22];
- target[18] = source[23];
- target[21] = source[24];
- target[3] = source[25];
- target[9] = source[26];
- target[7] = source[27];
- target[22] = source[28];
- target[1] = source[29];
- target[25] = source[30];
- target[5] = source[31];
- return BitArrayToByteArray(target);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement