get Secure Random - Android java.util

Android examples for java.util:Random

Description

get Secure Random

Demo Code


//package com.java2s;
import java.security.SecureRandom;

public class Main {
    public static final String RANDOM_ALGORITHM = "SHA1PRNG";

    public static SecureRandom getSecureRandom() {
        try {//www .j a  v  a  2  s  .co m
            return SecureRandom.getInstance(RANDOM_ALGORITHM, "Crypto");
        } catch (Exception e) {
            try {
                return SecureRandom.getInstance(RANDOM_ALGORITHM);
            } catch (Exception e1) {
                return new SecureRandom();
            }
        }
    }
}

Related Tutorials