File indexing completed on 2025-02-02 04:47:49
0001 /* 0002 * SPDX-FileCopyrightText: 2023 Albert Vaca Cintora <albertvaka@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 package org.kde.kdeconnect.Helpers; 0008 0009 0010 import java.security.SecureRandom; 0011 0012 public class RandomHelper { 0013 public static final SecureRandom secureRandom = new SecureRandom(); 0014 0015 private static final char[] symbols = ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" + 0016 "abcdefghijklmnopqrstuvwxyz" + 0017 "1234567890").toCharArray(); 0018 0019 0020 public static String randomString(int length) { 0021 char[] buffer = new char[length]; 0022 for (int idx = 0; idx < length; ++idx) { 0023 buffer[idx] = symbols[secureRandom.nextInt(symbols.length)]; 0024 } 0025 return new String(buffer); 0026 } 0027 0028 }