I know there are way better and more tested encryption methods, but I was wondering if the following code could be use for symmetric encryption?
var text = "hello";
var password = "mypass";
var message = hash(text) + encrypt(text, password);
function encrypt(text, password){
var key = hash(hash(text) XOR hash(password));
var passphrase = key;
while(passphrase.length < text.length){
key = hash(key);
passphrase += key;
}
passphrase = passphrase.substring(0, text.length);
return text XOR passphrase;
}
It can easily be decrypted if you know the password.
Is there any flaw to this simple algorithm?
N.B.: A similar question was asked here but the algorithm doesn't work...