Golang crypto/des.NewCipher() function example
package crypto/des
NewCipher creates and returns a new cipher.Block.
Golang crypto/des.NewCipher() function usage example
package main
import (
"fmt"
"crypto/des"
)
func main() {
key := "12345678" // 8 bytes! this is the DES block size in bytes
block,err := des.NewCipher([]byte(key))
if err != nil {
fmt.Println(err)
}
fmt.Printf("%d bytes NewCipher key with block size of %d bytes\n", len(key), block.BlockSize)
}
Output :
8 bytes NewCipher key with block size of 8752 bytes
Note : The key size must be exactly 8 bytes.
Reference :
Advertisement
Something interesting
Tutorials
+9.9k Golang : Check if user agent is a robot or crawler example
+12k Golang : Find and draw contours with OpenCV example
+13.6k Android Studio : Password input and reveal password example
+6.7k Golang : Check if password length meet the requirement
+19.6k Golang : Close channel after ticker stopped example
+6.5k Golang : Convert an executable file into []byte example
+36k Golang : Get file last modified date and time
+11.1k Golang : Web routing/multiplex example
+39.6k Golang : Remove dashes(or any character) from string
+39k Golang : How to iterate over a []string(array)
+9.6k Golang : Read file with ioutil
+19.6k Golang : Set or Add HTTP Request Headers