shuffledString function

String shuffledString(
  1. String s,
  2. bool cryptographicallySecure
)

Return a shuffled String.

Implementation

String shuffledString(String s, bool cryptographicallySecure) {
  List<int> codes = List.from(s.codeUnits);

  if (cryptographicallySecure) {
    codes.shuffle();
  } else {
    codes.shuffle(Random.secure());
  }

  return String.fromCharCodes(codes);
}