You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

328 lines
9.1 KiB

8 years ago
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1">
  6. <meta name="theme-color" content="#375EAB">
  7. <title>des - The Go Programming Language</title>
  8. <link type="text/css" rel="stylesheet" href="../../../lib/godoc/style.css">
  9. <link rel="stylesheet" href="../../../lib/godoc/jquery.treeview.css">
  10. <script type="text/javascript">window.initFuncs = [];</script>
  11. </head>
  12. <body>
  13. <div id='lowframe' style="position: fixed; bottom: 0; left: 0; height: 0; width: 100%; border-top: thin solid grey; background-color: white; overflow: auto;">
  14. ...
  15. </div><!-- #lowframe -->
  16. <div id="topbar" class="wide"><div class="container">
  17. <div class="top-heading" id="heading-wide"><a href="http://localhost:6060/">The Go Programming Language</a></div>
  18. <div class="top-heading" id="heading-narrow"><a href="http://localhost:6060/">Go</a></div>
  19. <a href="index.html#" id="menu-button"><span id="menu-button-arrow">&#9661;</span></a>
  20. <form method="GET" action="http://localhost:6060/search">
  21. <div id="menu">
  22. <a href="http://localhost:6060/doc/">Documents</a>
  23. <a href="http://localhost:6060/pkg/">Packages</a>
  24. <a href="http://localhost:6060/project/">The Project</a>
  25. <a href="http://localhost:6060/help/">Help</a>
  26. <a href="http://localhost:6060/blog/">Blog</a>
  27. <input type="text" id="search" name="q" class="inactive" value="Search" placeholder="Search">
  28. </div>
  29. </form>
  30. </div></div>
  31. <div id="page" class="wide">
  32. <div class="container">
  33. <h1>Package des</h1>
  34. <div id="nav"></div>
  35. <!--
  36. Copyright 2009 The Go Authors. All rights reserved.
  37. Use of this source code is governed by a BSD-style
  38. license that can be found in the LICENSE file.
  39. -->
  40. <!--
  41. Note: Static (i.e., not template-generated) href and id
  42. attributes start with "pkg-" to make it impossible for
  43. them to conflict with generated attributes (some of which
  44. correspond to Go identifiers).
  45. -->
  46. <script type='text/javascript'>
  47. document.ANALYSIS_DATA = null;
  48. document.CALLGRAPH = null;
  49. </script>
  50. <div id="short-nav">
  51. <dl>
  52. <dd><code>import "crypto/des"</code></dd>
  53. </dl>
  54. <dl>
  55. <dd><a href="index.html#pkg-overview" class="overviewLink">Overview</a></dd>
  56. <dd><a href="index.html#pkg-index" class="indexLink">Index</a></dd>
  57. <dd><a href="index.html#pkg-examples" class="examplesLink">Examples</a></dd>
  58. </dl>
  59. </div>
  60. <!-- The package's Name is printed as title by the top-level template -->
  61. <div id="pkg-overview" class="toggleVisible">
  62. <div class="collapsed">
  63. <h2 class="toggleButton" title="Click to show Overview section">Overview ▹</h2>
  64. </div>
  65. <div class="expanded">
  66. <h2 class="toggleButton" title="Click to hide Overview section">Overview ▾</h2>
  67. <p>
  68. Package des implements the Data Encryption Standard (DES) and the
  69. Triple Data Encryption Algorithm (TDEA) as defined
  70. in U.S. Federal Information Processing Standards Publication 46-3.
  71. </p>
  72. </div>
  73. </div>
  74. <div id="pkg-index" class="toggleVisible">
  75. <div class="collapsed">
  76. <h2 class="toggleButton" title="Click to show Index section">Index ▹</h2>
  77. </div>
  78. <div class="expanded">
  79. <h2 class="toggleButton" title="Click to hide Index section">Index ▾</h2>
  80. <!-- Table of contents for API; must be named manual-nav to turn off auto nav. -->
  81. <div id="manual-nav">
  82. <dl>
  83. <dd><a href="index.html#pkg-constants">Constants</a></dd>
  84. <dd><a href="index.html#NewCipher">func NewCipher(key []byte) (cipher.Block, error)</a></dd>
  85. <dd><a href="index.html#NewTripleDESCipher">func NewTripleDESCipher(key []byte) (cipher.Block, error)</a></dd>
  86. <dd><a href="index.html#KeySizeError">type KeySizeError</a></dd>
  87. <dd>&nbsp; &nbsp; <a href="index.html#KeySizeError.Error">func (k KeySizeError) Error() string</a></dd>
  88. </dl>
  89. </div><!-- #manual-nav -->
  90. <div id="pkg-examples">
  91. <h4>Examples</h4>
  92. <dl>
  93. <dd><a class="exampleLink" href="index.html#example_NewTripleDESCipher">NewTripleDESCipher</a></dd>
  94. </dl>
  95. </div>
  96. <h4>Package files</h4>
  97. <p>
  98. <span style="font-size:90%">
  99. <a href="http://localhost:6060/src/crypto/des/block.go">block.go</a>
  100. <a href="http://localhost:6060/src/crypto/des/cipher.go">cipher.go</a>
  101. <a href="http://localhost:6060/src/crypto/des/const.go">const.go</a>
  102. </span>
  103. </p>
  104. </div><!-- .expanded -->
  105. </div><!-- #pkg-index -->
  106. <div id="pkg-callgraph" class="toggle" style="display: none">
  107. <div class="collapsed">
  108. <h2 class="toggleButton" title="Click to show Internal Call Graph section">Internal call graph ▹</h2>
  109. </div> <!-- .expanded -->
  110. <div class="expanded">
  111. <h2 class="toggleButton" title="Click to hide Internal Call Graph section">Internal call graph ▾</h2>
  112. <p>
  113. In the call graph viewer below, each node
  114. is a function belonging to this package
  115. and its children are the functions it
  116. calls&mdash;perhaps dynamically.
  117. </p>
  118. <p>
  119. The root nodes are the entry points of the
  120. package: functions that may be called from
  121. outside the package.
  122. There may be non-exported or anonymous
  123. functions among them if they are called
  124. dynamically from another package.
  125. </p>
  126. <p>
  127. Click a node to visit that function's source code.
  128. From there you can visit its callers by
  129. clicking its declaring <code>func</code>
  130. token.
  131. </p>
  132. <p>
  133. Functions may be omitted if they were
  134. determined to be unreachable in the
  135. particular programs or tests that were
  136. analyzed.
  137. </p>
  138. <!-- Zero means show all package entry points. -->
  139. <ul style="margin-left: 0.5in" id="callgraph-0" class="treeview"></ul>
  140. </div>
  141. </div> <!-- #pkg-callgraph -->
  142. <h2 id="pkg-constants">Constants</h2>
  143. <pre>const <span id="BlockSize">BlockSize</span> = 8</pre>
  144. <p>
  145. The DES block size in bytes.
  146. </p>
  147. <h2 id="NewCipher">func <a href="http://localhost:6060/src/crypto/des/cipher.go?s=541:589#L17">NewCipher</a></h2>
  148. <pre>func NewCipher(key []<a href="../../builtin/index.html#byte">byte</a>) (<a href="../cipher/index.html">cipher</a>.<a href="../cipher/index.html#Block">Block</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  149. <p>
  150. NewCipher creates and returns a new cipher.Block.
  151. </p>
  152. <h2 id="NewTripleDESCipher">func <a href="http://localhost:6060/src/crypto/des/cipher.go?s=1141:1198#L39">NewTripleDESCipher</a></h2>
  153. <pre>func NewTripleDESCipher(key []<a href="../../builtin/index.html#byte">byte</a>) (<a href="../cipher/index.html">cipher</a>.<a href="../cipher/index.html#Block">Block</a>, <a href="../../builtin/index.html#error">error</a>)</pre>
  154. <p>
  155. NewTripleDESCipher creates and returns a new cipher.Block.
  156. </p>
  157. <div id="example_NewTripleDESCipher" class="toggle">
  158. <div class="collapsed">
  159. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  160. </div>
  161. <div class="expanded">
  162. <p class="exampleHeading toggleButton"><span class="text">Example</span></p>
  163. <p>Code:</p>
  164. <pre class="code">
  165. <span class="comment">// NewTripleDESCipher can also be used when EDE2 is required by</span>
  166. <span class="comment">// duplicating the first 8 bytes of the 16-byte key.</span>
  167. ede2Key := []byte(&#34;example key 1234&#34;)
  168. var tripleDESKey []byte
  169. tripleDESKey = append(tripleDESKey, ede2Key[:16]...)
  170. tripleDESKey = append(tripleDESKey, ede2Key[:8]...)
  171. _, err := des.NewTripleDESCipher(tripleDESKey)
  172. if err != nil {
  173. panic(err)
  174. }
  175. <span class="comment">// See crypto/cipher for how to use a cipher.Block for encryption and</span>
  176. <span class="comment">// decryption.</span>
  177. </pre>
  178. </div>
  179. </div>
  180. <h2 id="KeySizeError">type <a href="http://localhost:6060/src/crypto/des/cipher.go?s=266:287#L5">KeySizeError</a></h2>
  181. <pre>type KeySizeError <a href="../../builtin/index.html#int">int</a></pre>
  182. <h3 id="KeySizeError.Error">func (KeySizeError) <a href="http://localhost:6060/src/crypto/des/cipher.go?s=289:325#L7">Error</a></h3>
  183. <pre>func (k <a href="index.html#KeySizeError">KeySizeError</a>) Error() <a href="../../builtin/index.html#string">string</a></pre>
  184. <div id="footer">
  185. Build version go1.6.<br>
  186. Except as <a href="https://developers.google.com/site-policies#restrictions">noted</a>,
  187. the content of this page is licensed under the
  188. Creative Commons Attribution 3.0 License,
  189. and code is licensed under a <a href="http://localhost:6060/LICENSE">BSD license</a>.<br>
  190. <a href="http://localhost:6060/doc/tos.html">Terms of Service</a> |
  191. <a href="http://www.google.com/intl/en/policies/privacy/">Privacy Policy</a>
  192. </div>
  193. </div><!-- .container -->
  194. </div><!-- #page -->
  195. <!-- TODO(adonovan): load these from <head> using "defer" attribute? -->
  196. <script type="text/javascript" src="../../../lib/godoc/jquery.js"></script>
  197. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.js"></script>
  198. <script type="text/javascript" src="../../../lib/godoc/jquery.treeview.edit.js"></script>
  199. <script type="text/javascript" src="../../../lib/godoc/godocs.js"></script>
  200. </body>
  201. </html>