gou

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 22, 2021 License: MIT Imports: 16 Imported by: 0

README ΒΆ

🍜 gou

Installation
$ go get github.com/dongri/gou
Detect Credit Card Type
package main
import (
	"fmt"
	"github.com/dongri/gou"
)
func main() {
	cardType1 := gou.DetectCardType("4111111111111")
	fmt.Println(cardType1) // Visa
	cardType2 := gou.DetectCardType("5555555555554444")
	fmt.Println(cardType2) // Master
}
Date Format
package main
import (
	"fmt"
	"time"
	"github.com/dongri/gou"
)
func main() {
	time, _ := time.Parse("2006-01-02 15:04:05", "2015-03-04 23:29:23")
	formatedDate := gou.DateFormat(time, "%YεΉ΄%m月%dζ—₯ %Hζ™‚%Mεˆ†%Sη§’")
	fmt.Println(formatedDate) // 2015εΉ΄03月04ζ—₯ 23ζ™‚29εˆ†23η§’
}
Random
package main
import (
	"fmt"
	"github.com/dongri/gou"
)
func main() {
	random := new(gou.Random)
	random.UseNumber()
	random.UseSmallLetter()
	random.UseCapitalLetter()
	r := random.Random(20)
	fmt.Println(r) // 6Zyk2vOQYNIKmbIa6BcH
}
Sha1
package main
import (
	"fmt"
	"github.com/dongri/gou"
)
func main() {
	s := gou.Sha512Sum512("hello"))
	fmt.Println(s)
}
Cipher
package main
import (
	"fmt"
	"github.com/dongri/gou"
)
func main() {
	encryptedText, err := gou.EncryptString("passwordpasswordpasswordpassword", "hoge")
	fmt.Println(err, encryptedText)
}
Beacon
package main
import (
	"fmt"
	"github.com/dongri/gou"
)
func main() {
	major, minor := gou.PackBeacon(1,2,8)
	fmt.Println(major, minor)

	major, minor := gou.UnpackBeacon(0, 258,8)
	fmt.Println(major, minor)
}

License

The MIT License (MIT)

Copyright (c) 2015 Dongri Jin

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Documentation ΒΆ

Index ΒΆ

Constants ΒΆ

View Source
const (
	Visa     = "visa"
	Master   = "master"
	Amex     = "amex"
	Diners   = "diners"
	Discover = "discover"
	JCB      = "jcb"
	Other    = "other"
)

Type Const ...

View Source
const (
	BitTotal = 32
)

Beacon Bit

Variables ΒΆ

This section is empty.

Functions ΒΆ

func DateFormat ΒΆ

func DateFormat(t time.Time, layout string) string

DateFormat ...

func Decrypt ΒΆ

func Decrypt(cryptKey string, cipherText []byte) ([]byte, error)

Decrypt ...

func DecryptString ΒΆ

func DecryptString(cryptKey string, text string) (string, error)

DecryptString ...

func DetectCardType ΒΆ

func DetectCardType(number string) string

DetectCardType ...

func Encrypt ΒΆ

func Encrypt(cryptKey string, plainText []byte) ([]byte, error)

Encrypt ...

func EncryptString ΒΆ

func EncryptString(cryptKey string, text string) (string, error)

EncryptString ...

func PackBeacon ΒΆ

func PackBeacon(x, y int, minorBit uint) (int, int)

PackIBeacon is pack major, minor values params x, y is sequence value (24bit, 8bit) returns major, minor is real beacon value (16bit, 16bit)

func Sha1Sum ΒΆ

func Sha1Sum(s string) string

Sha1Sum ...

func Sha256Sum224 ΒΆ

func Sha256Sum224(s string) string

Sha256Sum224 ...

func Sha256Sum256 ΒΆ

func Sha256Sum256(s string) string

Sha256Sum256 ...

func Sha512Sum384 ΒΆ

func Sha512Sum384(s string) string

Sha512Sum384 ...

func Sha512Sum512 ΒΆ

func Sha512Sum512(s string) string

Sha512Sum512 ...

func UnpackBeacon ΒΆ

func UnpackBeacon(x, y int, minorBit uint) (int, int)

UnpackIBeacon is unpack major, minor values params x, y is real beacon value (16bit, 16bit) returns major, minor is sequence value (24bit, 8bit)

Types ΒΆ

type Random ΒΆ

type Random struct {
	Number        string
	SmallLetter   string
	CapitalLetter string
	Character     string
	Hiragana      string
	Katakana      string
	Hangul        string
	Shuzi         string
}

Random ...

func (*Random) Random ΒΆ

func (t *Random) Random(n int) string

Random ...

func (*Random) UseCapitalLetter ΒΆ

func (t *Random) UseCapitalLetter()

UseCapitalLetter ...

func (*Random) UseCharacter ΒΆ

func (t *Random) UseCharacter()

UseCharacter ...

func (*Random) UseHangul ΒΆ

func (t *Random) UseHangul()

UseHangul ...

func (*Random) UseHiragana ΒΆ

func (t *Random) UseHiragana()

UseHiragana ...

func (*Random) UseKatakana ΒΆ

func (t *Random) UseKatakana()

UseKatakana ...

func (*Random) UseNumber ΒΆ

func (t *Random) UseNumber()

UseNumber ...

func (*Random) UseShuzi ΒΆ

func (t *Random) UseShuzi()

UseShuzi ...

func (*Random) UseSmallLetter ΒΆ

func (t *Random) UseSmallLetter()

UseSmallLetter ...

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL