Professional Documents
Culture Documents
Sommaire:
Chiffrement AES
Chiffrement DES
Chiffrement RSA
Chiffrement de Hill
Chiffrement de César
Chiffrement de Vigénère
Chiffrement Affine
byte[] plaintext = {
// Texte à chiffrer (16 octets)
(byte) 0x32, (byte) 0x43, (byte) 0xf6, (byte) 0xa8,(byte)
0x88, (byte) 0x5a, (byte) 0x30, (byte) 0x8d,(byte) 0x31,
(byte) 0x31, (byte) 0x98, (byte) 0xa2,(byte) 0xe0, (byte)
0x37, (byte) 0x07, (byte) 0x34};
System.out.println("Le texte en
clair:"+byteArrayToHexString(plaintext));
byte[] ciphertext = encrypt(plaintext, key);
System.out.println("Texte chiffre : " +
byteArrayToHexString(ciphertext));
}
addRoundKey(state, roundKeys[0]);
return state;
}
// Rotation de mots
byte temp = previousRoundKey[0];
for (int i = 0; i < 3; i++) {
previousRoundKey[i] = previousRoundKey[i + 1];
}
previousRoundKey[3] = temp;
// Substitution de bytes
for (int i = 0; i < NB_WORDS; i++) {
previousRoundKey[i] = subByte(previousRoundKey[i]);
}
return roundKeys;
}
temp[4] = state[4];
temp[5] = state[9];
temp[6] = state[14];
temp[7] = state[3];
temp[8] = state[8];
temp[9] = state[13];
temp[10] = state[2];
temp[11] = state[7];
temp[12] = state[12];
temp[13] = state[1];
temp[14] = state[6];
temp[15] = state[11];
System.arraycopy(temp, 0, state, 0, BLOCK_SIZE);
}
import java.util.Arrays;
return roundKeys;
}
class RSA {
public static void main(String args[])
{
int p, q, n, z, d = 0, e, i;
Chiffrement Affine :
package Affine;
import java.util.Scanner;
import java.util.Scanner;
Chiffrement César:
package Cezar;
if (c > 'z') {
messageChiffre +=
(char)(message.charAt(i) - (26 - clef));
} else {
messageChiffre += c;
}
}
return messageChiffre;
}
if (c < 'a') {
messageDechiffre +=
(char)(messageChiffre.charAt(i) + (26 - clef));
} else {
messageDechiffre += c;
}
}
return messageDechiffre;
}
Chiffrement de Vigénère:
package Vigenere;