So my problem is the following : I'm trying to implement in Java a way to encrypt a message M (like from 1 character to let's say 1000) with a password P, chosen by the user (let's say "4z327yU10p"). I then want to hide the message in an image using a Pseudo Random Number Generator (PRNG) to choose the pixels. My seed is the password.
Here's my approach :
For (1): is this possible for a short password?
For (2): can AES be used for small messages?
For (3): how can I have random number in the interval of my image ? (0,...,480000) because my algorithm gives me an int
?
here's the code :
public void initSeed(String password){ //pour initier la seed avec le password
Message message = new Message();
message.initMessageASCII(password);
List <Integer> temp = message.getMsg();
byte[] vect = new byte[temp.size()];
for (int i=0; i< temp.size(); i++){
vect[i] = temp.get(i).byteValue();
}
this.seed = vect;
}
public void init() { //pour initier le remplissage du vecteur randList
SecureRandom random;
try {
random = SecureRandom.getInstance("SHA1PRNG"); //SHA1PRNG est un algorithme très efficace
random.setSeed(seed);
random.nextBytes(randList); //fonction pour créer les bytes aléatoires et les écrire dans "bytes"
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
}
I'll answer the separate questions (ask separate questions):
You can see this as a consultants curse though, I gave you what you asked for instead of what you need. For instance, you don't need the (not yet standardized) SHA-3 but you should use a PBKDF instead.