Screenies?
I've made some progress with encryption, generateKey() and decodeKey() have been reimplemented and seem to work correctly. I'm having issues decrypting data i'm sure if a bug if it's a bug in my encipher() method though ;P
What happened to posts auto-merging?
I found that on a paste for V23 RC4, in place of:Code:int c = (char)data.Substring(a, 1).ToCharArray()[0] ^ k;
It might just work, not sure thoughCode:int c = (char)s.charAt(a) ^ k;
[source]=http://pastebin.com/F5ankLTK
(I myself have been encountering problems porting the rc4 stuff to C++ :s)
Posted via Mobile Device
Last edited by Crossroads; 11-01-12 at 04:01 AM.
From the leaked server itself 8-)Code:package com.fuse.security; import java.security.SecureRandom; // Referenced classes of package com.fuse.security: // SecretKey public class SecretKeyCharIndex implements SecretKey { public SecretKeyCharIndex() { randomGen = new SecureRandom(); } public String generateKey() { int length = 30 + Math.abs(randomGen.nextInt() % 40); StringBuffer table = new StringBuffer(length); StringBuffer key = new StringBuffer(length); for(int i = 0; i < length; i++) { Character c = new Character("abcdefghijklmnopqrstuvwxyz1234567890".charAt(Math.abs(randomGen.nextInt() % "abcdefghijklmnopqrstuvwxyz1234567890".length()))); table.append(c); c = new Character("abcdefghijklmnopqrstuvwxyz1234567890".charAt(Math.abs(randomGen.nextInt() % "abcdefghijklmnopqrstuvwxyz1234567890".length()))); table.append(c); key.append(c); } return table.toString() + key.toString(); } public String decodeKey(String origKey) { String table = origKey.substring(0, origKey.length() / 2); String key = origKey.substring(origKey.length() / 2); long checkSum = 0L; for(int i = 0; i < table.length(); i++) { int offset = table.indexOf(key.charAt(i)); if(offset % 2 == 0) offset *= 2; if(i % 3 == 0) offset *= 3; if(offset < 0) offset = table.length() % 2; checkSum += offset; checkSum ^= offset << (i % 3) * 8; } return (new Long(checkSum)).toString(); } public static void main(String args[]) { SecretKeyCharIndex keyCode = new SecretKeyCharIndex(); for(int i = 0; i < 10; i++) { String key = keyCode.generateKey(); keyCode.decodeKey(key); } } public static final String VERSION = "$Id: SecretKeyCharIndex.java,v 1.12 2004/02/17 11:18:45 jambo Exp $"; private final int KEY_MINLENGTH = 30; private final int KEY_LENGTH_VARIATION = 40; private static final String characters = "abcdefghijklmnopqrstuvwxyz1234567890"; SecureRandom randomGen; }
This is from the same source Mike?
Code:package com.fuse.security; import java.util.*; import java.security.*; public class VerySimpleSecretKey implements SecretKey { long seed = System.currentTimeMillis(); public String generateKey() { Random rand = new Random((seed += System.currentTimeMillis() % 500)); StringBuffer sb = new StringBuffer(200); for(int i=0; i<20; i++) { sb.append(Math.abs(rand.nextInt() % 1000)); sb.append(" "); } return sb.toString(); } public String decodeKey(String key) { String s; int x, i=0; long z = 0; StringTokenizer zt = new StringTokenizer(key, " "); while(zt.hasMoreTokens()) { i++; s = zt.nextToken(); x = Integer.parseInt(s); z += (x+i%5); } System.out.println("z=" + z + "; i=" + i +"; res=" + 1000*Math.sin(z * 1.0)); return new Integer((int) (1000*Math.sin(z * 1.0))).toString(); } public static void main(String[] args) { VerySimpleSecretKey keyCode = new VerySimpleSecretKey(); System.out.println("Start"); for(int i=0; i<10; i++) { String key = keyCode.generateKey(); String decryptKey = keyCode.decodeKey(key); System.out.println(key); System.out.println(decryptKey); System.out.println(""); } } }
I release the leaked server files on SoM some time ago. They're very much in circulation... Lots of test classes in there too.
So yeah i've decided to forget about encryption for now, registration is nearly complete (ignores the database for now) username validation is performed using a regex instead of comparing each character like in some older servers. Once i bother to hookup the User model to hibernate i will implement username checks (already in use - easy change) i will add password validation and login should be easy enough to finish from there.