Skip to content

Instantly share code, notes, and snippets.

@eferm
Created September 5, 2010 13:29
Show Gist options
  • Select an option

  • Save eferm/566019 to your computer and use it in GitHub Desktop.

Select an option

Save eferm/566019 to your computer and use it in GitHub Desktop.
public static String explode(String ascii) {
// output string dimensioned for typical output size
StringBuilder output = new StringBuilder(RATIO*ascii.length());
for (int i = 0; i < ascii.length(); i++) {
String num = ascii.substring(i,i+1); // number to be hidden
// next occurence of num in pi at what index?
int index = pi.indexOf(num, INTERVAL+output.length());
// add some noise that doesn't match the corresponding digits in pi
for (int j = output.length(); j < index; j++) {
int k;
do {
k = (int) (10 * Math.random()); // random number, 0-9
} while (k == Integer.parseInt(pi.substring(j,j+1)));
output.append((int) k);
}
output.append(num);
}
return output.toString();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment