Skip to content

Instantly share code, notes, and snippets.

@bboston7
Last active August 29, 2015 14:16
Show Gist options
  • Save bboston7/af52ce7de2d0eef9be04 to your computer and use it in GitHub Desktop.
Save bboston7/af52ce7de2d0eef9be04 to your computer and use it in GitHub Desktop.
Shuffle String
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class ShuffStr {
public static void main(String[] args) {
System.setSecurityManager(null);
String str = "egg";
try {System.out.println(new String((char[])getUnsafe().defineClass("Shuffler", new byte[]{-54,-2,-70,-66,0,0,0,51,0,47,10,0,11,0,23,7,0,24,10,0,2,0,23,10,0,8,0,25,11,0,26,0,27,10,0,28,0,29,11,0,26,0,30,7,0,31,10,0,8,0,32,7,0,33,7,0,34,1,0,6,60,105,110,105,116,62,1,0,3,40,41,86,1,0,4,67,111,100,101,1,0,15,76,105,110,101,78,117,109,98,101,114,84,97,98,108,101,1,0,7,115,104,117,102,102,108,101,1,0,6,40,91,67,41,91,67,1,0,13,83,116,97,99,107,77,97,112,84,97,98,108,101,7,0,35,7,0,36,1,0,10,83,111,117,114,99,101,70,105,108,101,1,0,13,83,104,117,102,102,108,101,114,46,106,97,118,97,12,0,12,0,13,1,0,19,106,97,118,97,47,117,116,105,108,47,65,114,114,97,121,76,105,115,116,12,0,37,0,38,7,0,36,12,0,39,0,40,7,0,41,12,0,16,0,42,12,0,43,0,44,1,0,19,106,97,118,97,47,108,97,110,103,47,67,104,97,114,97,99,116,101,114,12,0,45,0,46,1,0,8,83,104,117,102,102,108,101,114,1,0,16,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,1,0,2,91,67,1,0,14,106,97,118,97,47,117,116,105,108,47,76,105,115,116,1,0,7,118,97,108,117,101,79,102,1,0,24,40,67,41,76,106,97,118,97,47,108,97,110,103,47,67,104,97,114,97,99,116,101,114,59,1,0,3,97,100,100,1,0,21,40,76,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,59,41,90,1,0,21,106,97,118,97,47,117,116,105,108,47,67,111,108,108,101,99,116,105,111,110,115,1,0,19,40,76,106,97,118,97,47,117,116,105,108,47,76,105,115,116,59,41,86,1,0,3,103,101,116,1,0,21,40,73,41,76,106,97,118,97,47,108,97,110,103,47,79,98,106,101,99,116,59,1,0,9,99,104,97,114,86,97,108,117,101,1,0,3,40,41,67,0,33,0,10,0,11,0,0,0,0,0,2,0,1,0,12,0,13,0,1,0,14,0,0,0,29,0,1,0,1,0,0,0,5,42,-73,0,1,-79,0,0,0,1,0,15,0,0,0,6,0,1,0,0,0,5,0,9,0,16,0,17,0,1,0,14,0,0,0,-98,0,4,0,6,0,0,0,82,-69,0,2,89,-73,0,3,76,42,77,44,-66,62,3,54,4,21,4,29,-94,0,27,44,21,4,52,54,5,43,21,5,-72,0,4,-71,0,5,2,0,87,-124,4,1,-89,-1,-27,43,-72,0,6,3,61,28,42,-66,-94,0,25,42,28,43,28,-71,0,7,2,0,-64,0,8,-74,0,9,85,-124,2,1,-89,-1,-25,42,-80,0,0,0,2,0,15,0,0,0,22,0,5,0,0,0,7,0,8,0,8,0,46,0,9,0,50,0,10,0,80,0,11,0,18,0,0,0,30,0,4,-1,0,16,0,5,7,0,19,7,0,20,7,0,19,1,1,0,0,-8,0,29,-4,0,5,1,-6,0,27,0,1,0,21,0,0,0,2,0,22},0,697).getMethods()[0].invoke(null,str.toCharArray()))); } catch (Exception e) {e.printStackTrace();}
}
public static Unsafe getUnsafe() {
try {
Field f = Unsafe.class.getDeclaredField("theUnsafe");
f.setAccessible(true);
return (Unsafe)f.get(null);
} catch (Exception e) {
}
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment