payload almost done
This commit is contained in:
1 parent
77bfcba5b1
commit
09d0f237d5
16 files changed
+690
-118
No files matched your search
+20
-2
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"crypto/rsa"
|
||||
"encoding/binary"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
@@ -14,11 +15,12 @@ func B(x int64) *big.Int {
|
||||
}
|
||||
|
||||
type MockRandomReader struct {
|
||||
random *rand.Rand
|
||||
readLength int
|
||||
random *rand.Rand
|
||||
}
|
||||
|
||||
func NewMockRandomReader() *MockRandomReader {
|
||||
return &MockRandomReader{rand.New(rand.NewSource(99))}
|
||||
return &MockRandomReader{0, rand.New(rand.NewSource(99))}
|
||||
}
|
||||
|
||||
func (this *MockRandomReader) getNextFourRandomBytes() []byte {
|
||||
@@ -31,9 +33,14 @@ func (this *MockRandomReader) Read(p []byte) (n int, err error) {
|
||||
for i := 0; i < len(p); i += 4 {
|
||||
copy(p[i:], this.getNextFourRandomBytes())
|
||||
}
|
||||
this.readLength += len(p)
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (this *MockRandomReader) GetReadLength() int {
|
||||
return this.readLength
|
||||
}
|
||||
|
||||
func (this *MockRandomReader) GetRandomBytes(size int) []byte {
|
||||
ret := make([]byte, size)
|
||||
this.Read(ret)
|
||||
@@ -74,6 +81,17 @@ func (this *MockIoWriter) ReaderAt() io.ReaderAt {
|
||||
return bytes.NewReader(this.state)
|
||||
}
|
||||
|
||||
func (this *MockIoWriter) IsValidJson() bool {
|
||||
m := make(map[string]interface{})
|
||||
l := make([]interface{}, 0, 100)
|
||||
if json.Unmarshal(this.Bytes(), &m) == nil {
|
||||
return true
|
||||
} else if json.Unmarshal(this.Bytes(), &l) == nil {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func Range(length int) []byte {
|
||||
ret := make([]byte, length)
|
||||
for i, _ := range ret {
|
||||
|
||||
Reference in new issue
Block a user