Permalink
Browse files

fixed the hell out of Read

  • Loading branch information...
1 parent a2d0769 commit 0544a4802287c324c57b2db50c72453043cebc13 @ammario committed Feb 17, 2017
Showing with 3 additions and 12 deletions.
  1. +1 −0 README.md
  2. +2 −12 rand.go
View
@@ -41,6 +41,7 @@ __That's 10.3 mb/s to 370 mb/s__
## Algorithm
1) Generate iv/key with `crypto/rand`
+
2) Spam AES-CTR
## Install
View
@@ -42,18 +42,8 @@ func New() *Rand {
//Read reads into b.
//It never returns an error.
func (r *Rand) Read(b []byte) (n int, err error) {
- //almost certainly can be optmized
- passes := len(b) / len(r.buf)
- for i := 0; i <= passes; i++ {
- if i == passes {
- leftover := len(b) % len(r.buf)
- r.stream.XORKeyStream(b[leftover:], r.buf[:leftover])
- return
- }
- r.stream.XORKeyStream(b[n:], r.buf)
- n += len(r.buf)
- }
- return
+ r.stream.XORKeyStream(b, b)
+ return len(b), nil
}
//WriteTo writes to a writer

0 comments on commit 0544a48

Please sign in to comment.