Class Loader Example: Rotate All Bytes of Hello.class by Amount "key"
Java Source
Rotated Class File
// Apply (for example) as follows:
// javac Hello.java
// mv Hello.class Hello_Plain.class
// java Slide Hello_Plain.class Hello.class 1
import java.io.*;
public class Slide {
public static void main (String args[]) {
if (args.length != 3) {
System.out.println("Usage: java Slide in-file out-file key");
return;
}
try {
FileInputStream in = new FileInputStream(args[0]);
FileOutputStream out = new FileOutputStream(args[1]);
int key = Integer.parseInt(args[2]);
int ch;
while ((ch = in.read()) != -1) {
byte c = (byte)((ch + key) % 256);
out.write (c);
}
in.close();
out.close();
}
catch (IOException e) {
System.out.println("Error: "+e.getMessage());
}
}
}