StringExtensions.kt 418 B

1234567891011121314151617
  1. /*
  2. * Nextcloud - Android Client
  3. *
  4. * SPDX-FileCopyrightText: 2024 Your Name <your@email.com>
  5. * SPDX-License-Identifier: AGPL-3.0-or-later
  6. */
  7. package com.nextcloud.utils.extensions
  8. fun String.getRandomString(length: Int): String {
  9. val allowedChars = ('A'..'Z') + ('a'..'z') + ('0'..'9')
  10. val result = (1..length)
  11. .map { allowedChars.random() }
  12. .joinToString("")
  13. return this + result
  14. }