Register for your free account! | Forgot your password?

You last visited: Today at 00:17

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



C# AES256

Discussion on C# AES256 within the .NET Languages forum part of the Coders Den category.

Reply
 
Old   #1
 
badguy4you's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 178
C# AES256

in blowfish when i encrypt some text with the same key every time it gives me different value
ex.
Code:
Key = EPVP
plainText = badguy4you
every time i encrypt plainText with (EPVP) it give me a different value and only (EPVP) can decrypt it(in blowfish)


on the other hand when i try AES256 with the same credentials (CBC mode)
if the key is the same it gives the same result @ every encryption

NOTE(i dont want to generate random key every time cuz i am creating server \ client communication and i want to store the key in both of them so only the one with that key could encrypt the Messages)--OR tell me a good way to use AES in server client communication--

So the question is : how could i make AES encrypt the same text with the same key every time but giving non equal values (like BLOWFISH)


_______A funny thing away from the post
badguy4you is offline  
Old 07/26/2012, 10:00   #2
 
kissein's Avatar
 
elite*gold: 0
Join Date: Sep 2005
Posts: 427
Received Thanks: 87
Quote:
NOTE(i dont want to generate random key every time cuz i am creating server \ client communication
why no ssl ?
kissein is offline  
Thanks
1 User
Old 07/26/2012, 11:36   #3
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
same key, same text, different result, sounds legit.
MoepMeep is offline  
Old 07/26/2012, 17:12   #4
 
badguy4you's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 178
Quote:
Originally Posted by MoepMeep View Post
same key, same text, different result, sounds legit.
And sounds ur a donkey !

you ever tried blowfish ?

ECB :The disadvantage of this method is that identical plaintext blocks are encrypted into identical ciphertext blocks

The results of ECB - Same Message Encrypted 10 Times (Results in HEX)

3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD
3F 89 AD 58 3C C8 21 CD


This encryption is deterministic since the same input always results in the same output. Without knowing the actual message, we know that the message is 8 bytes long and repeated 10 times. It’s the way ECB works and it has some advantages and disadvantages:

___________________________________

CBC : IBM invented the cipher-block chaining (CBC) mode of operation in 1976.[5] In CBC mode, each block of plaintext is XORed with the previous ciphertext block before being encrypted. This way, each ciphertext block depends on all plaintext blocks processed up to that point. To make each message unique

The results of CBC -- Same Message Encrypted 10 Times (Results in HEX)

B1 2C 46 D5 E1 73 E3 52
22 1F BA 57 F1 83 F3 4A
63 2F 21 37 4D 9E 93 55
40 BE AA C9 58 2F 5A 5D
FA 84 60 45 9C 99 AB 6F
C5 71 70 52 61 4A DA E8
21 00 0F 93 35 6C AC 45
EA C4 6E 3C EA 50 83 A7
FF 1A 28 9F 7C 69 49 ED
EF 88 CA 25 F6 F2 98 1C

As you can see, the repetitions are gone, even though you are encrypting 10 times the same message. The advantage is clear: you cannot deduce the plaintext by looking at the encrypted blocks separately. However, it has some consequences:


___________________
So its a small search got me that dont just replay to increase your posts with shits as i told you before and if you dont know anything about encrypting go learn about it , otherwise if you just entering my threads to SHIT dont do that again i am begging you
badguy4you is offline  
Old 07/26/2012, 21:07   #5

 
boxxiebabee's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,222
Received Thanks: 500
Quote:
Originally Posted by MoepMeep View Post
same key, same text, different result, sounds legit.
Na klar geht das bei einigen Verschlüsselungen, auch bei AES.

Code:
	public static byte[] PolyBabyEncrypt(byte[] input, string key)
        {
            byte[] bkey = Encoding.ASCII.GetBytes(key);
            var Out = new byte[input.Length + 1];
            int x = new Random().Next(1, 255);
            for (int i = 0; i <= input.Length - 1; i++) Out[i] = (byte) (input[i] ^ (bkey[i%bkey.Length] + x) & 255);
            Out[input.Length] = (byte) x;
            return Out;
        }

        public static byte[] PolyDexEncrypt(byte[] plain, string key)
        {
            byte[] bkey = Encoding.ASCII.GetBytes(key);
            byte[] expandedKey;
            byte[] dKey = bkey;
            int length = plain.Length;
            if (dKey.Length >= length) expandedKey = dKey;
            else
            {
                byte[] rconst = BitConverter.GetBytes(Math.Round(Math.PI, 3));
                var result = new byte[length];
                Buffer.BlockCopy(dKey, 0, result, 0, dKey.Length);
                for (int i = dKey.Length; i < length; i++)
                    result[i] = (byte) ((dKey[(i - dKey.Length)%dKey.Length] ^ (result[i - 1]))%256);
                for (int round = 0; round < 5; round++)
                {
                    result[0] = (byte) (result[0] ^ rconst[round]);
                    for (int i = 1; i < result.Length; i++)
                        result[i] = (byte) (((result[i] ^ (byte) (rconst[round] << (i%3))) ^ result[i - 1])%256);
                }
                expandedKey = result;
            }
            byte[] wholeState = plain;
            var magic = (byte) new Random().Next(byte.MaxValue);
            Array.Resize(ref wholeState, plain.Length + 1);
            wholeState[wholeState.Length - 1] = magic;
            for (int i = 0; i < wholeState.Length - 1; i++)
                wholeState[i] = (byte) (wholeState[i] ^ expandedKey[i] ^ magic);
            return wholeState;
        }

        public static byte[] PolyCloudEncrypt(byte[] input, string key)
        {
            byte[] bkey = Encoding.ASCII.GetBytes(key);
            var rnd = new Random();
            int salt = rnd.Next(1, 50);
            var finVal = new byte[input.Length + 1];
            finVal[input.Length] = (byte) salt;
            short kc = 0;
            for (int index = 0; index < input.Length; index++)
            {
                if (kc >= bkey.Length) kc = 0;
                finVal[index] = (byte) (input[index] + (input.Length%bkey.Length) + (bkey[kc]) - salt);
                kc++;
            }
            return finVal;
        }

	public static byte[] PolyStairsCrypt(byte[] data, string key)
        {
            byte[] bkey = Encoding.ASCII.GetBytes(key);
            Array.Resize(ref data, data.Length + 1);
            data[data.Length - 1] = (byte) new Random().Next(1, 255);
            for (int i = data.Length; i >= 0; i += -1)
            {
                data[i%data.Length] =
                    (byte) ((((data[i%data.Length]) + (data[(i + 1)%data.Length]))%256) ^ bkey[i%bkey.Length]);
            }
            return data;
        }

        public static byte[] PolyRevCrypt(byte[] data, string pass)
        {
            var rndByte = (byte) new Random().Next(1, 255);
            byte[] passByte = Encoding.ASCII.GetBytes(pass);
            var Out = new byte[data.Length + 1];
            int u = 0;
            for (int i = 0; i <= data.Length - 1; i++)
            {
                Out[i] = (byte) ((data[i] ^ passByte[u]) ^ rndByte);
                Array.Reverse(passByte);
                if (u == passByte.Length - 1) u = 0;
                else u += 1;
            }
            Array.Resize(ref Out, Out.Length);
            Out[Out.Length - 1] = rndByte;
            Array.Reverse(Out);
            return Out;
        }

public static byte[] PolyAESEncrypt(byte[] plainText, string key)
        {
            byte[] enced;
            using (SymmetricAlgorithm algo = new RijndaelManaged())
            {
                byte[] bkey;
                byte[] salt;
                using (var rngAlgo = new RNGCryptoServiceProvider())
                {
                    algo.Mode = CipherMode.CBC;
                    bkey = Encoding.ASCII.GetBytes(key);

                    algo.GenerateIV();
                    salt = new byte[32];
                    rngAlgo.GetBytes(salt);
                }
                using (var pwDeriveAlg = new Rfc2898DeriveBytes(bkey, salt, 2000))
                {
                    algo.Key = pwDeriveAlg.GetBytes(32);
                }

                using (ICryptoTransform encTransform = algo.CreateEncryptor())
                {
                    enced = encTransform.TransformFinalBlock(plainText, 0, plainText.Length);
                }

                int origLength = enced.Length;
                Array.Resize(ref enced, enced.Length + salt.Length);
                Buffer.BlockCopy(salt, 0, enced, origLength, salt.Length);

                origLength = enced.Length;
                Array.Resize(ref enced, enced.Length + algo.IV.Length);
                Buffer.BlockCopy(algo.IV, 0, enced, origLength, algo.IV.Length);
            }

            return enced;
        }
boxxiebabee is offline  
Thanks
1 User
Old 07/27/2012, 10:53   #6
 
elite*gold: 42
Join Date: Jun 2008
Posts: 5,425
Received Thanks: 1,888
Meh, I really forgot about that, shame on me But a 'part' of the key actually changes, don't forget that

Quote:

So the question is : how could i make AES encrypt the same text with the same key every time but giving non equal values (like BLOWFISH)
You answered your own question, good job. Looks like googling instead of asking nonstop helps, doesn't it?
MoepMeep is offline  
Thanks
1 User
Old 07/27/2012, 20:53   #7
 
badguy4you's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 477
Received Thanks: 178
Quote:
Originally Posted by MoepMeep View Post
Meh, I really forgot about that, shame on me But a 'part' of the key actually changes, don't forget that



You answered your own question, good job. Looks like googling instead of asking nonstop helps, doesn't it?
You are right but the problem with me is with AES i already achieved this with Blowfish , i am using Blowfish with same key in client and server and same messages are encrypted in different ways every time

but in AES not , Although i am using the chaining mode CBC , i still get same result , not like BLOWFISH
badguy4you is offline  
Reply


Similar Threads Similar Threads
Flyff v17 möglicher SourceCode AES256 crypted
04/29/2012 - Flyff Private Server - 14 Replies
Hallöle Ich habe seit längeren die VPN IP Range von Galalabs gescannt und am 12. Mai in der Zeit von 0:00 bis 22:29 waren alle DMZ Rechner public, Ich hatte dadurch Zugriff auf einen offenen MSSQL Server und das Passwort war !%agala! (lol) wie es zu erwarten war :D. Dadurch hatte ich dann Zugriff auf das Vpn Netzwerk. Auf den Netzwerk-Laufwerk //patch-gpotato wahr diese Datei. Download :...



All times are GMT +1. The time now is 00:18.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.