Last active
February 6, 2021 11:57
-
-
Save Carlos-Augusto/f107dbcdd3e37c08339fb17dc5a04c64 to your computer and use it in GitHub Desktop.
Random Secret 32 bytes using Bouncy Castle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.{SecureRandom, Security} | |
import org.bouncycastle.jce.provider.BouncyCastleProvider | |
import org.bouncycastle.util.encoders.Base64 | |
Security.addProvider(new BouncyCastleProvider()) | |
val secretKey = new Array[Byte](33) | |
val random = SecureRandom.getInstance("DEFAULT", "BC") | |
random.nextBytes(secretKey) | |
Base64.toBase64String(secretKey) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment