How to generate an OAuth nonce in android?

To generate a OAuth nonce in android I tried -

                byte[] nonce = new byte[16];

                try {
                    rand = SecureRandom.getInstance("SHA1PRNG");
                } catch (NoSuchAlgorithmException e) {
                    e.printStackTrace();
                }

                String oauth_nonce = rand.toString();

                Log.d("nonce value", oauth_nonce);

It gives something like - java.security.SecureRandom@58957gy8

Is this the correct way to generate a nonce ? If no, can you suggest a correct way ?

Answers


You can try with this

import java.util.UUID;


String nonce = UUID.randomUUID().toString();

Need Your Help

java cannot refer to non-final variable

java class gwt

The following code continues to give me:

Changes were not reflecting into the database if I perform any database operation via Signalr hub class

c# asp.net-mvc kendo-ui signalr asp.net-identity

I am developing ASP.NET MVC application using entity framework and for data access i am following unitofwork and repository pattern. For UI, I am using kendo.