Example usage for org.apache.shiro.crypto RandomNumberGenerator nextBytes

List of usage examples for org.apache.shiro.crypto RandomNumberGenerator nextBytes

Introduction

In this page you can find the example usage for org.apache.shiro.crypto RandomNumberGenerator nextBytes.

Prototype

ByteSource nextBytes(int numBytes);

Source Link

Document

Generates a byte array of the specified length filled with random data.

Usage

From source file:com.bridge.utils.SecurityUtils.java

public static String[] digest(String password) {

    RandomNumberGenerator generator = new SecureRandomNumberGenerator();

    String salt = generator.nextBytes(32).toBase64();

    password = new Sha256Hash(password, salt, 1024).toBase64();

    return new String[] { password, salt };
}