diff options
Diffstat (limited to 'devdocs/go/crypto%2Fmd5%2Findex.html')
| -rw-r--r-- | devdocs/go/crypto%2Fmd5%2Findex.html | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/devdocs/go/crypto%2Fmd5%2Findex.html b/devdocs/go/crypto%2Fmd5%2Findex.html new file mode 100644 index 00000000..a41a5b8d --- /dev/null +++ b/devdocs/go/crypto%2Fmd5%2Findex.html @@ -0,0 +1,42 @@ +<h1> Package md5 </h1> <ul id="short-nav"> +<li><code>import "crypto/md5"</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 md5 implements the MD5 hash algorithm as defined in RFC 1321. </p> +<p>MD5 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="#New">func New() hash.Hash</a></li> +<li><a href="#Sum">func Sum(data []byte) [Size]byte</a></li> +</ul> <div id="pkg-examples"> <h3>Examples</h3> <dl> <dd><a class="exampleLink" href="#example_New">New</a></dd> <dd><a class="exampleLink" href="#example_New_file">New (File)</a></dd> <dd><a class="exampleLink" href="#example_Sum">Sum</a></dd> </dl> </div> <h3>Package files</h3> <p> <span>md5.go</span> <span>md5block.go</span> <span>md5block_decl.go</span> </p> <h2 id="pkg-constants">Constants</h2> <p>The blocksize of MD5 in bytes. </p> +<pre data-language="go">const BlockSize = 64</pre> <p>The size of an MD5 checksum in bytes. </p> +<pre data-language="go">const Size = 16</pre> <h2 id="New">func <span>New</span> </h2> <pre data-language="go">func New() hash.Hash</pre> <p>New returns a new hash.Hash computing the MD5 checksum. The Hash also implements <span>encoding.BinaryMarshaler</span> and <span>encoding.BinaryUnmarshaler</span> to marshal and unmarshal the internal state of the hash. </p> <h4 id="example_New"> <span class="text">Example</span> +</h4> <p>Code:</p> <pre class="code" data-language="go">h := md5.New() +io.WriteString(h, "The fog is getting thicker!") +io.WriteString(h, "And Leon's getting laaarger!") +fmt.Printf("%x", h.Sum(nil)) +</pre> <p>Output:</p> <pre class="output" data-language="go">e2c569be17396eca2a2e3c11578123ed +</pre> <h4 id="example_New_file"> <span class="text">Example (File)</span> +</h4> <p>Code:</p> <pre class="code" data-language="go"> +f, err := os.Open("file.txt") +if err != nil { + log.Fatal(err) +} +defer f.Close() + +h := md5.New() +if _, err := io.Copy(h, f); err != nil { + log.Fatal(err) +} + +fmt.Printf("%x", h.Sum(nil)) +</pre> <h2 id="Sum">func <span>Sum</span> <span title="Added in Go 1.2">1.2</span> </h2> <pre data-language="go">func Sum(data []byte) [Size]byte</pre> <p>Sum returns the MD5 checksum of the data. </p> <h4 id="example_Sum"> <span class="text">Example</span> +</h4> <p>Code:</p> <pre class="code" data-language="go">data := []byte("These pretzels are making me thirsty.") +fmt.Printf("%x", md5.Sum(data)) +</pre> <p>Output:</p> <pre class="output" data-language="go">b0804ec967f48520697662a204f5fe72 +</pre><div class="_attribution"> + <p class="_attribution-p"> + © Google, Inc.<br>Licensed under the Creative Commons Attribution License 3.0.<br> + <a href="http://golang.org/pkg/crypto/md5/" class="_attribution-link">http://golang.org/pkg/crypto/md5/</a> + </p> +</div> |
