To make this more applicable to other people I want to know how realistic it is the write code that will encrypt a message to the point where it is unlikely to be decrypted without the password. I figured the best way to do this was making hash algorithms and adding randomness. So how realistic is it for a code amateur to write sound encryption? Would any engineer be able to crack amateur encryption algorithms? EDIT: several of the answers have discussed attacks on the memory of computer which is useful information that I appreciate but I am more interested in knowing if the message can be decrypted directly. I assume the cryptoanalyser does not have access to the computer the obfuscated the message because if he did he could just look at my source code anyway and find the decryption algorithm. Here is my example:
public class Keys { // hold the methods and information used to lock, unlock, make the key, get the "keypad" after it has been locked, and a static method to change int[] to long[]
// Fields
private String passphrase;
private long[] key;
private long keynum;
private long[] pad;
Random rands = new Random();
// Constructors
public Keys (String passphrase) // makes a key based of the given passphrase
{
this.passphrase = passphrase;
key = keycipher(this.passphrase.toCharArray());
key = keyfix(key);
keynum = key[0];
for (int i=1; i < key.length && key[i] != 0; i=i+1)
if (i <key.length -1 && key[i] == key[i+1])
keynum = keynum *key[i] +1;
else if (i+1 < key.length)
keynum = keynum * key[i] - key[i+1];
else
keynum = keynum * key[i] -1;
}
/**
*used to lock and save a message in the pad field
* @param message2lock the input which will be locked using the key and saved as the field pad
*/
public void lock (String message2lock)
{
Message2Num holenums = new Message2Num(message2lock); // message2nums converts inout string to number []
holenums.step1(); //uses custom cipher to change each character to a long
long[] hole =new long[holenums.step2().length];
int t =0;
for(int g : holenums.step2())
/* // Step 2 uses the cipher from step 1 and hides it in random numbers by doubling the array length
then making every even number in the array length a random number and every odd number the last random number
minus the original cipher number
*/
{
hole[t] = (long) g;
t++;
}
hole = this.padding(hole);
double p = (double) keynum;
p = 3* Math.cos(p);
long z = (long) p;
for ( int i =0; i< hole.length; i++)
hole[i] = hole[i] * keynum + z;
hole = Message2Num.addcommas(hole);
pad =hole;
}