I need a unique string for every device of my app. The app sends requests to the server and I need unique identifier on the server side to recognize the requester. I used the mac address of the device before but I was pointed out that the using of the mac leads to privacy violation. So I decided now to generate a string instead of using the mac.
What do you thing, can I do replace the get_mac_address()
with the getSessionId()
and be sure that the String will occur just once in the database?
Code:
private String get_mac_address() {
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);
WifiInfo wInfo = wifiManager.getConnectionInfo();
String macAddress = wInfo.getMacAddress();
return macAddress;
}
public void getSessionId() {
SecureRandom random = new SecureRandom();
sessionId = new BigInteger(130, random).toString(32);
}