iedoc wrote:i might be able to write a program or just figure out how to decrypt it.
Ok, maybe it is AES encrypted. I don't have the PSP code, but just a quick warm-up for you:
Code: Select all
unencrypted: This is a secret text
encrypted: lpclfmgfjddoelfdpnhdhjeokbmoolfmfdckldakbbijknegnahimbbcelfpjndj
And something you don't get as easy from the PSP, some Java code, which created the encryption (I've omitted trivial things like class declaration, imports etc.):
Code: Select all
public static String asciiEncodeBytes(byte[] bytes) {
	StringBuffer out = new StringBuffer(bytes.length * 2);
	for (int i = 0; i < bytes.length; i++) {
		int high = (((int) bytes[i]) & 0xf0) >> 4;
		int low = bytes[i] & 0xf;
		out.append((char) (high + 'a'));
		out.append((char) (low + 'a'));
	}
	return out.toString();
}
public static byte[] asciiDecodeBytes(String bytes) {
	int len = bytes.length() / 2;
	byte[] result = new byte[len];
	int j = 0;
	for (int i = 0; i < len; i++) {
		int high = (int) (bytes.charAt(j++) - 'a');
		int low = (int) (bytes.charAt(j++) - 'a');
		result[i] = (byte) ((high << 4) | low);
	}
	return result;
}
private static Cipher cip;
private static Key key;
private static void initAes() throws InvalidKeySpecException, NoSuchAlgorithmException, NoSuchPaddingException {
	if (cip == null) {
		// create key
		final byte keyArray[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
		key = new Key() {
			public byte[] getEncoded() {
				return keyArray;
			}
			public String getAlgorithm() {
				return "AES";
			}
			public String getFormat() {
				return "RAW";
			}
		};
		// create cipher object
		cip = Cipher.getInstance("AES/ECB/PKCS5Padding");
	}
}
public static String aesEncrypt(String text) throws IOException, GeneralSecurityException {
	if (text == null)
		return text;
	initAes();
	cip.init(Cipher.ENCRYPT_MODE, key);
	byte[] input = text.getBytes("utf8");
	ByteArrayOutputStream outs = new ByteArrayOutputStream();
	CipherOutputStream cout = new CipherOutputStream(outs, cip);
	cout.write(input);
	cout.close();
	return asciiEncodeBytes(outs.toByteArray());
}
public static String aesDecrypt(String text) throws IOException, GeneralSecurityException {
	if (text == null)
		return text;
	initAes();
	cip.init(Cipher.DECRYPT_MODE, key);
	byte[] input = asciiDecodeBytes(text);
	ByteArrayOutputStream out = new ByteArrayOutputStream();
	CipherOutputStream cout = new CipherOutputStream(out, cip);
	cout.write(input);
	cout.close();
	return new String(out.toByteArray(), "utf8");
}
Now you only have to find the right keyArray values. Bonus: encrypt some own text, I'll verify it. If you've managed this, you can start to think about the PSP crypting.