generate Salt from Base64 - Android java.security

Android examples for java.security:Decrypt Encrypt

Description

generate Salt from Base64

Demo Code


//package com.java2s;
import java.security.SecureRandom;
import android.util.Base64;

public class Main {
    public static String generateSalt() {
        SecureRandom sr = new SecureRandom();
        byte[] salt = new byte[8];
        sr.nextBytes(salt);//from w w  w  . j ava 2s.  c o  m
        return Base64.encodeToString(salt, Base64.DEFAULT);

    }
}

Related Tutorials