Documentation ¶
Index ¶
- func Address(pubKey []byte) int64
- func AddressToString(address int64) (ret string)
- func BinMarshal(out *[]byte, v interface{}) (*[]byte, error)
- func BinUnmarshal(out *[]byte, v interface{}) error
- func Bytes2Float(bytes []byte) float64
- func CBCDecrypt(key, ciphertext, iv []byte) ([]byte, error)
- func CBCEncrypt(key, text, iv []byte) ([]byte, error)
- func CRC64(input []byte) uint64
- func CalculateMd5(filePath string) ([]byte, error)
- func CheckECDSA(public []byte, forSign string, signature []byte) (bool, error)
- func CheckSum(val []byte) int
- func DecodeLenInt64(data *[]byte) (int64, error)
- func DecodeLength(buf *[]byte) (ret int64, err error)
- func EGSMoney(money string) string
- func EncodeLenByte(out *[]byte, buf []byte) *[]byte
- func EncodeLenInt64(data *[]byte, x int64) *[]byte
- func EncodeLength(length int64) []byte
- func Escape(data string) string
- func EscapeForJSON(data string) string
- func EscapeName(name string) string
- func FieldToBytes(v interface{}, num int) []byte
- func FillLeft(slice []byte) []byte
- func FillLeft64(slice []byte) []byte
- func Float2Bytes(float float64) []byte
- func GenBytesKeys() ([]byte, []byte, error)
- func GenHexKeys() (string, string, error)
- func GetShared(public string) (string, string, error)
- func GetSharedHex(private, public string) (string, error)
- func GetSharedKey(private, public []byte) (shared []byte, err error)
- func HexToInt64(input string) (ret int64)
- func IsValidAddress(address string) bool
- func JSSignToBytes(in string) ([]byte, error)
- func KeyToAddress(pubKey []byte) string
- func NumString(in string) string
- func PKCS7Padding(src []byte, blockSize int) []byte
- func PKCS7UnPadding(src []byte) ([]byte, error)
- func PrivateToPublic(key []byte) []byte
- func PrivateToPublicHex(hexkey string) string
- func SharedDecrypt(private, ciphertext []byte) ([]byte, error)
- func SharedEncrypt(public, text []byte) ([]byte, error)
- func SignECDSA(privateKey string, forSign string) (ret []byte, err error)
- func StringToAddress(address string) (result int64)
- func StripTags(value string) string
- func Time32() uint32
- func UintToBytes(val uint32) []byte
- type Update
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressToString ¶
AddressToString converts int64 address to EGAAS address as XXXX-...-XXXX.
func BinMarshal ¶
BinMarshal converts v parameter to []byte slice.
func BinUnmarshal ¶
BinUnmarshal converts []byte slice which has been made with BinMarshal to v
func CBCDecrypt ¶
CBCDecrypt decrypts the text by using key. It uses CBC mode of AES.
func CBCEncrypt ¶
CBCEncrypt encrypts the text by using the key parameter. It uses CBC mode of AES.
func CalculateMd5 ¶
CalculateMd5 calculates MD5 hash of the file
func CheckECDSA ¶
CheckECDSA checks if forSign has been signed with corresponding to public the private key
func DecodeLenInt64 ¶
DecodeLenInt64 gets int64 from []byte and shift the slice. The []byte should be encoded with EncodeLengthPlusInt64.
func DecodeLength ¶
DecodeLength decodes []byte to int64 and shifts buf. Bytes must be encoded with EncodeLength function.
0x43 => 67 0x820400 => 1024 0x830f4240 => 1000000
func EncodeLenByte ¶
EncodeLenByte appends the length of the slice (EncodeLength) + the slice.
func EncodeLenInt64 ¶
EncodeLenInt64 appends int64 to []byte as uint8 + little-endian order of uint8.
65000 => [0x02, 0xe8, 0xfd]
func EncodeLength ¶
EncodeLength encodes int64 number to []byte. If it is less than 128 then it returns []byte{length}. Otherwise, it returns (0x80 | len of int64) + int64 as BigEndian []byte
67 => 0x43 1024 => 0x820400 1000000 => 0x830f4240
func EscapeForJSON ¶
EscapeForJSON replaces quote to slash and quote
func EscapeName ¶
EscapeName deletes unaccessable characters for input name(s)
func FieldToBytes ¶
FieldToBytes returns the value of n-th field of v as []byte
func FillLeft64 ¶
FillLeft64 fills the slice by zero at left if the size of the slice is less than 32.
func GenBytesKeys ¶
GenBytesKeys generates a random pair of ECDSA private and public binary keys.
func GenHexKeys ¶
GenHexKeys generates a random pair of ECDSA private and public hex keys.
func GetShared ¶
GetShared returns the combined key for the specified public key. If the text is encrypted with this key then it can be decrypted with the shared key made from private key and the returned public key (pub). All keys are hex strings.
func GetSharedHex ¶
GetSharedHex generates a shared key from private and public key. All keys are hex string.
func GetSharedKey ¶
GetSharedKey creates and returns the shared key = private * public. public must be the public key from the different private key.
func IsValidAddress ¶
IsValidAddress checks if the specified address is EGAAS address.
func JSSignToBytes ¶
JSSignToBytes converts hex signature which has got from the browser to []byte
func KeyToAddress ¶
KeyToAddress converts a public key to EGAAS address XXXX-...-XXXX.
func PKCS7Padding ¶
PKCS7Padding realizes PKCS#7 encoding which is described in RFC 5652.
func PKCS7UnPadding ¶
PKCS7UnPadding realizes PKCS#7 decoding.
func PrivateToPublic ¶
PrivateToPublic returns the public key for the specified private key.
func PrivateToPublicHex ¶
PrivateToPublicHex returns the hex public key for the specified hex private key.
func SharedDecrypt ¶
SharedDecrypt decrypts the ciphertext by using private key.
func SharedEncrypt ¶
SharedEncrypt creates a shared key and encrypts text. The first 32 characters are the created public key. The cipher text can be only decrypted with the original private key.
func StringToAddress ¶
StringToAddress converts string EGAAS address to int64 address. The input address can be a positive or negative number, or EGAAS address in XXXX-...-XXXX format. Returns 0 when error occurs.
func UintToBytes ¶
UintToBytes converts 32-byte value into [4]byte (BigEndian)