-
Notifications
You must be signed in to change notification settings - Fork 148
/
Copy pathcrypto_des.htm
74 lines (73 loc) · 4.45 KB
/
crypto_des.htm
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head profile="http://a9.com/-/spec/opensearch/1.1/">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="../assets/site.css" rel="stylesheet">
<title>crypto/des</title>
</head>
<body>
<div class="container">
<h2 id="pkg-overview">package des</h2>
<p><code>import "crypto/des"</code>
<p>des包实现了DES标准和TDEA算法,参见U.S. Federal Information Processing Standards Publication 46-3。</p>
<h3 id="pkg-index" class="section-header">Index <a class="permalink" href="#pkg-index">¶</a></h3>
<a href="../main.html"><h3>返回首页</h3></a>
</br>
<li><a href="#pkg-constants">Constants</a></li>
<li><a href="#KeySizeError">type KeySizeError</a></li>
<ul>
<li><a href="#KeySizeError.Error">func (k KeySizeError) Error() string</a></li>
</ul>
<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>
</ul>
<h3 id="pkg-constants">Constants <a class="permalink" href="#pkg-index">¶</a></h3>
<pre>const <span id="BlockSize">BlockSize</span> = 8</pre>
<p>DES字节块的大小。</p>
<h3 id="KeySizeError">type <a title="View Source" href="https://github.com/golang/go/blob/master/src/crypto/des/cipher.go?name=release#15">KeySizeError</a> <a class="permalink" href="#pkg-index">¶</a></h3>
<pre>type KeySizeError <a href="builtin.htm#int">int</a></pre>
<h4 id="KeySizeError.Error">func (KeySizeError) <a title="View Source" href="https://github.com/golang/go/blob/master/src/crypto/des/cipher.go?name=release#17">Error</a> <a class="permalink" href="#pkg-index">¶</a></h4>
<pre class="funcdecl">func (k <a href="#KeySizeError">KeySizeError</a>) Error() <a href="builtin.htm#string">string</a></pre>
<h3 id="NewCipher">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/crypto/des/cipher.go?name=release#27">NewCipher</a> <a class="permalink" href="#pkg-index">¶</a></h3>
<pre class="funcdecl">func NewCipher(key []<a href="builtin.htm#byte">byte</a>) (<a href="crypto/cipher.htm">cipher</a>.<a href="crypto/cipher.htm#Block">Block</a>, <a href="builtin.htm#error">error</a>)</pre>
<p>创建并返回一个使用DES算法的cipher.Block接口。</p>
<h3 id="NewTripleDESCipher">func <a title="View Source" href="https://github.com/golang/go/blob/master/src/crypto/des/cipher.go?name=release#49">NewTripleDESCipher</a> <a class="permalink" href="#pkg-index">¶</a></h3>
<pre class="funcdecl">func NewTripleDESCipher(key []<a href="builtin.htm#byte">byte</a>) (<a href="crypto/cipher.htm">cipher</a>.<a href="crypto/cipher.htm#Block">Block</a>, <a href="builtin.htm#error">error</a>)</pre>
<p>创建并返回一个使用TDEA算法的cipher.Block接口。</p>
<div class="panel-group">
<div class="panel panel-default" id="example-NewTripleDESCipher">
<div class="panel-heading" onclick="document.getElementById('ex-NewTripleDESCipher').style.display = document.getElementById('ex-NewTripleDESCipher').style.display=='none'?'block':'none';">Example</div>
<div id="ex-NewTripleDESCipher" class="panel-collapse collapse">
<div class="panel-body">
<pre>
<span class="com">// NewTripleDESCipher can also be used when EDE2 is required by</span>
<span class="com">// duplicating the first 8 bytes of the 16-byte key.</span>
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)
}
<span class="com">// See crypto/cipher for how to use a cipher.Block for encryption and</span>
<span class="com">// decryption.</span>
</pre>
</div>
</div>
</div>
</div>
</div>
<div id="x-footer" class="clearfix">
<div class="container">
<a href="http://studygolang.com/" target="_blank">Go语言中文网</a>
<span class="text-muted">|</span> <a href="http://golang.org/" target="_blank">Go Language</a>
<span class="pull-right"><a href="#">Back to top</a></span>
</div>
</div>
<script src="../assets/jquery-2.0.3.min.js"></script>
<script src="../assets/bootstrap.min.js"></script>
<script src="../assets/site.js"></script>
</body>
</html>