KirkCypher: show gamekey

This commit is contained in:
codestation 2011-07-22 23:15:04 -04:30
parent 21fbdd1aef
commit 4f0f67cabc

View file

@ -25,18 +25,33 @@ import jpcsp.crypto.CryptoEngine;
import keys.GameKeys;
public class KirkCypher implements GameKeys {
static final String HEXES = "0123456789ABCDEF";
private static String getHex(byte[] raw) {
if (raw == null) {
return null;
}
final StringBuilder hex = new StringBuilder(2 * raw.length);
for (final byte b : raw) {
hex.append(HEXES.charAt((b & 0xF0) >> 4)).append(HEXES.charAt((b & 0x0F))).append(' ');
}
return hex.toString();
}
public void decrypt(String file) {
try {
RandomAccessFile fd = new RandomAccessFile(file, "rw");
byte byte_bt[] = new byte[(int)fd.length()];
fd.read(byte_bt);
fd.seek(0);
System.out.print("Decrypting savedata (KIRK engine)");
byte out[] = new CryptoEngine().DecryptSavedata(byte_bt, byte_bt.length, gamekey, 1);
System.out.println("Decrypting savedata (KIRK engine): " + byte_bt.length + " bytes");
System.out.println("Gamekey: " + getHex(gamekey));
byte out[] = new CryptoEngine().DecryptSavedata(byte_bt, byte_bt.length, gamekey, 0);
fd.write(out);
fd.setLength(out.length);
fd.close();
System.out.println("Finished");
System.out.println("Finished (" + out.length + " bytes)");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
@ -50,11 +65,12 @@ public class KirkCypher implements GameKeys {
byte byte_bt[] = new byte[(int)fd.length()];
fd.read(byte_bt);
fd.seek(0);
System.out.println("Encrypting savedata (KIRK engine)");
System.out.println("Encrypting savedata (KIRK engine): " + byte_bt.length + " bytes");
byte out[] = new CryptoEngine().EncryptSavedata(byte_bt, byte_bt.length, gamekey, 0);
fd.write(out);
fd.setLength(out.length);
fd.close();
System.out.println("Finished");
System.out.println("Finished (" + out.length + " bytes)");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {