all InfoSec news
Some notes on symmetric encryption in golang
May 19, 2024, 10:42 a.m. | nigel447
DEV Community dev.to
Working today on passing around secure parameters I came across the post
Instead of LibSodium, you should use the nacl/box library that is part of golang.org/x/crypto. [1]
here is a simple example using the suggested libraries
the encrypt import suggested [1]
"golang.org/x/crypto/nacl/secretbox"
func getRandomNonce() ([]byte, [24]byte) {
iv := make([]byte, 24)
if _, err := io.ReadFull(rand.Reader, iv); err != nil {
panic(err)
}
return iv, [24]byte(iv)
}
func encryptSecret(plainText []byte) ([]byte, [24]byte) {
nonce, np := getRandomNonce()
symKey := [32]byte(secretKeyBytes) …
box crypto cryptography encrypt encryption func go golang import libraries library org philosophy simple symmetric symmetric encryption today working
More from dev.to / DEV Community
Jobs in InfoSec / Cybersecurity
CyberSOC Technical Lead
@ Integrity360 | Sandyford, Dublin, Ireland
Cyber Security Strategy Consultant
@ Capco | New York City
Cyber Security Senior Consultant
@ Capco | Chicago, IL
Sr. Product Manager
@ MixMode | Remote, US
Security Compliance Strategist
@ Grab | Petaling Jaya, Malaysia
Cloud Security Architect, Lead
@ Booz Allen Hamilton | USA, VA, McLean (1500 Tysons McLean Dr)