github.com/shogo82148/std@v1.22.1-0.20240327122250-4e474527810c/crypto/des/example_test.go (about)

     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 "github.com/shogo82148/std/crypto/des"
     8  
     9  func ExampleNewTripleDESCipher() {
    10  
    11  	// NewTripleDESCipherは、最初の8バイトを16バイトのキーの複製として使用することで、EDE2が必要な場合にも使用することができます。
    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  	// 暗号化と復号化にcipher.Blockを使用する方法は、crypto/cipherを参照してください。
    24  }