distort static method

String distort(
  1. String value
)

Distorts a string by randomly replacing characters in it.

  • value a string to distort. Returns a distored string.

Implementation

/// - [value]    a string to distort.
/// Returns        a distored string.

static String distort(String value) {
  value = value.toLowerCase();

  //Capitalize the first letter of the string 'value'.
  if (RandomBoolean.chance(1, 5)) {
    value = value.substring(0, 1).toUpperCase() + value.substring(1);
  }

  //Add a symbol to the end of the string 'value'
  if (RandomBoolean.chance(1, 3)) {
    value = value + RandomString.pickChar(RandomString._symbols);
  }

  return value;
}