summaryrefslogtreecommitdiff
path: root/devdocs/go/crypto%2Fdes%2Findex.html
blob: 1a7845ae38be0887dded6a2a62eb55c634adbe54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<h1> Package des  </h1>     <ul id="short-nav">
<li><code>import "crypto/des"</code></li>
<li><a href="#pkg-overview" class="overviewLink">Overview</a></li>
<li><a href="#pkg-index" class="indexLink">Index</a></li>
<li><a href="#pkg-examples" class="examplesLink">Examples</a></li>
</ul>     <h2 id="pkg-overview">Overview </h2> <p>Package des implements the Data Encryption Standard (DES) and the Triple Data Encryption Algorithm (TDEA) as defined in U.S. Federal Information Processing Standards Publication 46-3. </p>
<p>DES is cryptographically broken and should not be used for secure applications. </p>     <h2 id="pkg-index">Index </h2>  <ul id="manual-nav">
<li><a href="#pkg-constants">Constants</a></li>
<li><a href="#NewCipher">func NewCipher(key []byte) (cipher.Block, error)</a></li>
<li><a href="#NewTripleDESCipher">func NewTripleDESCipher(key []byte) (cipher.Block, error)</a></li>
<li><a href="#KeySizeError">type KeySizeError</a></li>
<li> <a href="#KeySizeError.Error">func (k KeySizeError) Error() string</a>
</li>
</ul> <div id="pkg-examples"> <h3>Examples</h3>  <dl> <dd><a class="exampleLink" href="#example_NewTripleDESCipher">NewTripleDESCipher</a></dd> </dl> </div> <h3>Package files</h3> <p>  <span>block.go</span> <span>cipher.go</span> <span>const.go</span>  </p>   <h2 id="pkg-constants">Constants</h2> <p>The DES block size in bytes. </p>
<pre data-language="go">const BlockSize = 8</pre> <h2 id="NewCipher">func <span>NewCipher</span>  </h2> <pre data-language="go">func NewCipher(key []byte) (cipher.Block, error)</pre> <p>NewCipher creates and returns a new <span>cipher.Block</span>. </p>
<h2 id="NewTripleDESCipher">func <span>NewTripleDESCipher</span>  </h2> <pre data-language="go">func NewTripleDESCipher(key []byte) (cipher.Block, error)</pre> <p>NewTripleDESCipher creates and returns a new <span>cipher.Block</span>. </p>   <h4 id="example_NewTripleDESCipher"> <span class="text">Example</span>
</h4> <p>Code:</p> <pre class="code" data-language="go">
// NewTripleDESCipher can also be used when EDE2 is required by
// duplicating the first 8 bytes of the 16-byte key.
ede2Key := []byte("example key 1234")

var tripleDESKey []byte
tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
tripleDESKey = append(tripleDESKey, ede2Key[:8]...)

_, err := des.NewTripleDESCipher(tripleDESKey)
if err != nil {
    panic(err)
}

// See crypto/cipher for how to use a cipher.Block for encryption and
// decryption.
</pre>   <h2 id="KeySizeError">type <span>KeySizeError</span>  </h2> <pre data-language="go">type KeySizeError int</pre> <h3 id="KeySizeError.Error">func (KeySizeError) <span>Error</span>  </h3> <pre data-language="go">func (k KeySizeError) Error() string</pre><div class="_attribution">
  <p class="_attribution-p">
    &copy; Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br>
    <a href="http://golang.org/pkg/crypto/des/" class="_attribution-link">http://golang.org/pkg/crypto/des/</a>
  </p>
</div>