Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danhper/securerandom
https://github.com/danhper/securerandom
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/danhper/securerandom
- Owner: danhper
- Created: 2014-07-18T02:56:33.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-07-19T02:49:30.000Z (over 10 years ago)
- Last Synced: 2024-06-19T17:42:34.939Z (6 months ago)
- Language: Go
- Size: 133 KB
- Stars: 25
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# securerandom
Port of Ruby `securerandom` module for Golang.
The following functions are implemented.```go
func RandomBytes(n int) ([]byte, error)
func Base64(n int, padded bool) (string, error)
func UrlSafeBase64(n int, padded bool) (string, error)
func Hex(n int) (string, error)
func Uuid() (string, error)
```## Sample usage
```go
package mainimport (
"fmt"
sr "github.com/tuvistavie/securerandom"
)func main() {
b, _ := sr.Base64(10, true)
fmt.Println(b)
b, _ = sr.Hex(10)
fmt.Println(b)
b, _ = sr.Uuid()
fmt.Println(b)
}
```For more information, check out the [documentation of the ruby module](http://ruby-doc.org/stdlib-2.1.0/libdoc/securerandom/rdoc/SecureRandom.html).