2020-06-28 23:41:19 +08:00

32 lines
2.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<div class="container">
<h1 id="pkg-overview">package rc4</h1>
<p><code>import "crypto/rc4"</code>
</p><p>rc4包实现了RC4加密算法参见Bruce Schneier's Applied Cryptography。</p>
<h2 id="KeySizeError">type <a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4.go?name=release#20" title="View Source">KeySizeError</a> </h2>
<pre>type KeySizeError <a href="builtin.htm#int">int</a></pre>
<h3 id="KeySizeError.Error">func (KeySizeError) <a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4.go?name=release#22" title="View Source">Error</a> </h3>
<pre class="funcdecl">func (k <a href="#KeySizeError">KeySizeError</a>) Error() <a href="builtin.htm#string">string</a></pre>
<h2 id="Cipher">type <a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4.go?name=release#15" title="View Source">Cipher</a> </h2>
<pre>type Cipher struct {
<span class="com">// 内含隐藏或非导出字段</span>
}</pre>
<p>Cipher是一个使用特定密钥的RC4实例本类型实现了cipher.Stream接口。</p>
<h3 id="NewCipher">func <a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4.go?name=release#28" title="View Source">NewCipher</a> </h3>
<pre class="funcdecl">func NewCipher(key []<a href="builtin.htm#byte">byte</a>) (*<a href="#Cipher">Cipher</a>, <a href="builtin.htm#error">error</a>)</pre>
<p>NewCipher创建并返回一个新的Cipher。参数key是RC4密钥至少1字节最多256字节。</p>
<h3 id="Cipher.Reset">func (*Cipher) <a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4.go?name=release#47" title="View Source">Reset</a> </h3>
<pre class="funcdecl">func (c *<a href="#Cipher">Cipher</a>) Reset()</pre>
<p>Reset方法会清空密钥数据以便将其数据从程序内存中清除以免被破解</p>
<h3 id="Cipher.XORKeyStream">func (*Cipher) <a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4_asm.go?name=release#13" title="View Source">XORKeyStream</a> </h3>
<pre class="funcdecl">func (c *<a href="#Cipher">Cipher</a>) XORKeyStream(dst, src []<a href="builtin.htm#byte">byte</a>)</pre>
<p>XORKeyStream方法将src的数据与秘钥生成的伪随机位流取XOR并写入dst。dst和src可指向同一内存地址但如果指向不同则其底层内存不可重叠。</p>
<h2 id="pkg-note-bug">Bugs </h2>
<p><a href="https://github.com/golang/go/blob/master/src/crypto/rc4/rc4.go?name=release#9" title="View Source"></a> RC4被广泛使用但设计上的缺陷使它很少用于较新的协议中。 </p></div>