Skip to content

Instantly share code, notes, and snippets.

@Carlos-Augusto
Last active February 6, 2021 11:57
Show Gist options
  • Save Carlos-Augusto/f107dbcdd3e37c08339fb17dc5a04c64 to your computer and use it in GitHub Desktop.
Save Carlos-Augusto/f107dbcdd3e37c08339fb17dc5a04c64 to your computer and use it in GitHub Desktop.
Random Secret 32 bytes using Bouncy Castle
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