...

Source file src/crypto/des/example_test.go

Documentation: crypto/des

		 1  // Copyright 2013 The Go Authors. All rights reserved.
		 2  // Use of this source code is governed by a BSD-style
		 3  // license that can be found in the LICENSE file.
		 4  
		 5  package des_test
		 6  
		 7  import "crypto/des"
		 8  
		 9  func ExampleNewTripleDESCipher() {
		10  	// NewTripleDESCipher can also be used when EDE2 is required by
		11  	// duplicating the first 8 bytes of the 16-byte key.
		12  	ede2Key := []byte("example key 1234")
		13  
		14  	var tripleDESKey []byte
		15  	tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
		16  	tripleDESKey = append(tripleDESKey, ede2Key[:8]...)
		17  
		18  	_, err := des.NewTripleDESCipher(tripleDESKey)
		19  	if err != nil {
		20  		panic(err)
		21  	}
		22  
		23  	// See crypto/cipher for how to use a cipher.Block for encryption and
		24  	// decryption.
		25  }
		26  

View as plain text