java - Convert string to rubbish -
i trying create function takes in input string , returns rubbish string value
string foobar (string input) { string rubbish; ...... ...... returns rubbish } the rubbish string value similar below

i appreciate if able provide me sample function or guide me on how go doing it
if want function return same garbage same input string, work fine.
public string rubbish(string input) { string result = ""; long seed = 0; long size = 0; for(int = 0; < input.length(); ++) { seed += input.charat(i); } seed %= long.max_value; size = seed % 3000; random rand = new random(seed); for(int = 0; < size; ++) { result += (char)rand.nextint(256); } return result; } additionally, if want string different each time, can change new random(seed) new random() , it'll randomize string.
Comments
Post a Comment