For two way encryption, most algorithms uses an x or operator, comparing the binary code of a key and the binary data of the input, this might not be right for you then, as you cant use a key... however, this is how it works:
Input data: 10011101101001
Key: 123 = 1111011
The key is smaller than the input, so it needs to be repeated:
Input data: 10011101101001
Key: 123 = 11110111111011
(in Java use one variable to count in a for each or a while loop trough all the bits of the data input...) Now use the x or principal to generate the encryoted result(two way hash) loop trough each bit in the input data and compare it to the corresponding bit in the key, if identical, add 0 to the result, if not, add 1 to the result... The result will then be:
Input data: 10011101101001
Key: 123 = 11110111111011
Result = 01101010010010
To decrypt the data, simply run the encrypted data trough:
Input data: 01101010010010
Key: 123 = 11110111111011
Result = 10011101101001
Ideally you would use a hash function like sha, md5, ripemd etc... to generate the key, then turn it in to binary... if you cant use a premade algorithm, you could make your own algorithm to generate the key to be compared... just make shure all the bits in the input are dependant upon each other to generate the result... example:
password: abcdefghi
abc= 123456789(a=1,b=2,c=3 etc...)
now loop every bit(digit) and add them together with a counter, example:
count=0
result =""
foreach digit in password do{
result = result & (digit+result[count-1])*count)
count = count+1
}
result=
(1+0)*1 = 1
(2+1)*2 = 6
(3+2)*3 = 15
(4+3)*4 = 28
(5+4)*5 = 45
(6+5)*6 = 66
(7+6)*7 = 91
(8+7)*8 = 120
(9+8)*9 = 153
key result= 16152845669120153
Binary: 111001011000101110110101110100001110000011100010011001
(This is a very poor example thou... you should think trough a good algorithm... one where the two starting inputs combine and form the third, and then the third and fourth go together with the result of the first combining to generate the fith result...)
but then again, if you cant use a key, you cant use this...