Documentation
¶
Index ¶
- Constants
- Variables
- func BigIntn(n *big.Int) *big.Int
- func ByteArrayToInt(arr []byte) int
- func ByteArrayToInt16(arr []byte) int16
- func ByteArrayToInt32(arr []byte) int32
- func ByteArrayToInt64(arr []byte) int64
- func Bytes(n int) []byte
- func CreateRamdisk(diskSize int) (mountVolume string)
- func DestroyRamdisk(mountPoint string)
- func DumpFileToScreen(fileName string)
- func EightByteArrayToInt(arr []byte) int
- func EightByteArrayToInt32(arr []byte) int32
- func Entropy128() [16]byte
- func Entropy192() [24]byte
- func Entropy256() [32]byte
- func FileExists(path string) bool
- func Float64() float64
- func GenerateRandomPin() string
- func GenerateSeed(key string, nonce int32) (seed int32)
- func GenerateSeed32Bytes(key string, nonce int32) (seed []byte)
- func GenerateSeedAndNonce(key string) (seed, nonce int32)
- func GenerateSeedAndNonce32Bytes(key string) (seed []byte, nonce int32)
- func GetCiphers(data ecdata) (ciphers [][]int)
- func GetDefaultMountPoint() string
- func GetNonce(data ecdata) (nonce int32)
- func GetRandomName() string
- func GetRandomNameWithPin() string
- func GetRandomName_Sized(size int) (rname string)
- func InitMountPoint()
- func Int16ToByteArray(num int16) []byte
- func Int32ToByteArray(num int32) []byte
- func Int64ToByteArray(num int64) []byte
- func IntToByteArray(num int) []byte
- func Intn(n int) int
- func Join(chunksdir string, joinedfile string)
- func MakeRamdisk(diskSize int64) (mountVolume string)
- func Perm(n int) []int
- func Read(b []byte) (int, error)
- func ReadCipherData(filename string) (data ecdata)
- func SetDefaultMountPoint(mountpoint string)
- func Shuffle(n int, swap func(i, j int))
- func Split(fileToBeChunked string) (chunksdir string)
- func Uint64n(n uint64) uint64
- func WriteByteArray(data []byte, filename string)
- func WriteCipherData(nonce int32, ciphers *[][]int, filename string)
- func WriteIndexArray(cipherindicies []int, filename string)
- func WriteIndexArrays(ciphers [][]int, filename string)
- func WriteNonce(nonce int32, filename string)
- type AdditiveCongruential
- type Frand
- type RNG
- func (r *RNG) BigIntn(n *big.Int) *big.Int
- func (r *RNG) Bytes(n int) []byte
- func (r *RNG) Entropy128() (entropy [16]byte)
- func (r *RNG) Entropy192() (entropy [24]byte)
- func (r *RNG) Entropy256() (entropy [32]byte)
- func (r *RNG) Float64() float64
- func (r *RNG) Intn(n int) int
- func (r *RNG) Perm(n int) []int
- func (r *RNG) Read(b []byte) (int, error)
- func (r *RNG) Shuffle(n int, swap func(i, j int))
- func (r *RNG) Uint64n(n uint64) uint64
- type Source
Constants ¶
const FileChunk = 1 * (1 << 20) // 1 MB, change this to your requirement
const G = M * 1024
const M = 1024 * 1034
Variables ¶
var Reader rngReader
Reader is a global, shared instance of a cryptographically strong pseudo- random generator. Reader is safe for concurrent use by multiple goroutines.
Functions ¶
func ByteArrayToInt ¶
func ByteArrayToInt16 ¶
func ByteArrayToInt32 ¶
func ByteArrayToInt64 ¶
func CreateRamdisk ¶
func DestroyRamdisk ¶
func DestroyRamdisk(mountPoint string)
func DumpFileToScreen ¶
func DumpFileToScreen(fileName string)
func EightByteArrayToInt ¶
func EightByteArrayToInt32 ¶
func Entropy128 ¶
func Entropy128() [16]byte
Entropy128 is a helper function that returns 128 bits of random data.
func Entropy192 ¶
func Entropy192() [24]byte
Entropy192 is a helper function that returns 192 bits of random data.
func Entropy256 ¶
func Entropy256() [32]byte
Entropy256 is a helper function that returns 256 bits of random data.
func FileExists ¶
func GenerateRandomPin ¶ added in v1.1.1
func GenerateRandomPin() string
func GenerateSeed ¶
func GenerateSeed32Bytes ¶
func GenerateSeedAndNonce ¶
func GetCiphers ¶
func GetCiphers(data ecdata) (ciphers [][]int)
func GetDefaultMountPoint ¶
func GetDefaultMountPoint() string
func GetRandomName ¶ added in v1.1.1
func GetRandomName() string
func GetRandomNameWithPin ¶ added in v1.1.1
func GetRandomNameWithPin() string
GetRandomName returns mnemonicoded random name
func GetRandomName_Sized ¶ added in v1.1.1
func InitMountPoint ¶
func InitMountPoint()
func Int16ToByteArray ¶
func Int32ToByteArray ¶
func Int64ToByteArray ¶
func IntToByteArray ¶
func MakeRamdisk ¶ added in v1.1.0
func ReadCipherData ¶
func ReadCipherData(filename string) (data ecdata)
func SetDefaultMountPoint ¶
func SetDefaultMountPoint(mountpoint string)
func Shuffle ¶
Shuffle randomly permutes n elements by repeatedly calling swap in the range [0,n). It panics if n < 0.
func WriteByteArray ¶
func WriteCipherData ¶
func WriteIndexArray ¶
func WriteIndexArrays ¶
func WriteNonce ¶
Types ¶
type AdditiveCongruential ¶
type AdditiveCongruential struct {
// contains filtered or unexported fields
}
func CreateAdditiveCongruential ¶
func CreateAdditiveCongruential(seed int32) AdditiveCongruential
func (*AdditiveCongruential) Random ¶
func (rng *AdditiveCongruential) Random(r int32) int32
type Frand ¶
func CreateFrand ¶
type RNG ¶
type RNG struct {
// contains filtered or unexported fields
}
An RNG is a cryptographically-strong RNG constructed from the ChaCha stream cipher.
func New ¶
func New() *RNG
New returns a new RNG instance. The instance is seeded with entropy from crypto/rand, albeit indirectly; its seed is generated by a global "master" RNG, which itself is seeded from crypto/rand. This means the frand package only reads system entropy once, at startup.
func NewCustom ¶
NewCustom returns a new RNG instance seeded with the provided entropy and using the specified buffer size and number of ChaCha rounds. It panics if len(seed) != 32, bufsize < 32, or rounds != 8, 12 or 20.
func (*RNG) Entropy128 ¶
Entropy128 is a helper function that returns 128 bits of random data.
func (*RNG) Entropy192 ¶
Entropy192 is a helper function that returns 192 bits of random data.
func (*RNG) Entropy256 ¶
Entropy256 is a helper function that returns 256 bits of random data.
func (*RNG) Read ¶
Read fills b with random data. It always returns len(b), nil.
For performance reasons, calling Read once on a "large" buffer (larger than the RNG's internal buffer) will produce different output than calling Read multiple times on smaller buffers. If deterministic output is required, clients should call Read in a loop; when copying to an io.Writer, use io.CopyBuffer instead of io.Copy. Callers should also be aware that b is xored with random data, not directly overwritten; this means that the new contents of b depend on its previous contents.
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
A Source is a math/rand-compatible source of entropy. It is safe for concurrent use by multiple goroutines
func NewSource ¶
func NewSource() *Source
NewSource returns a source for use with the math/rand package.