|
|
@ -21,7 +21,7 @@ func NewCryptionReader(stream cipher.Stream, reader io.Reader) *CryptionReader {
|
|
|
|
|
|
|
|
|
|
|
|
func (this *CryptionReader) Read(data []byte) (int, error) {
|
|
|
|
func (this *CryptionReader) Read(data []byte) (int, error) {
|
|
|
|
if this.reader == nil {
|
|
|
|
if this.reader == nil {
|
|
|
|
return 0, common.ErrorAlreadyReleased
|
|
|
|
return 0, common.ErrObjectReleased
|
|
|
|
}
|
|
|
|
}
|
|
|
|
nBytes, err := this.reader.Read(data)
|
|
|
|
nBytes, err := this.reader.Read(data)
|
|
|
|
if nBytes > 0 {
|
|
|
|
if nBytes > 0 {
|
|
|
@ -49,7 +49,7 @@ func NewCryptionWriter(stream cipher.Stream, writer io.Writer) *CryptionWriter {
|
|
|
|
|
|
|
|
|
|
|
|
func (this *CryptionWriter) Write(data []byte) (int, error) {
|
|
|
|
func (this *CryptionWriter) Write(data []byte) (int, error) {
|
|
|
|
if this.writer == nil {
|
|
|
|
if this.writer == nil {
|
|
|
|
return 0, common.ErrorAlreadyReleased
|
|
|
|
return 0, common.ErrObjectReleased
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.stream.XORKeyStream(data, data)
|
|
|
|
this.stream.XORKeyStream(data, data)
|
|
|
|
return this.writer.Write(data)
|
|
|
|
return this.writer.Write(data)
|
|
|
|