common

package module
v0.0.0-...-6b07dec Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 20 Imported by: 0

README

multi-central-net-lib

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func B64ToBytes

func B64ToBytes(encodedStr string) ([]byte, error)

Функция для декодирования вектора байт из Base64

func B64ToString

func B64ToString(encodedStr string) (string, error)

Функция для декодирования строки из Base64

func BytesToB64

func BytesToB64(input []byte) string

Кодирует входной вектор байт в Base64.

func CompareTime

func CompareTime(timestamp string, referenceTime time.Time) (bool, error)

func CountFilesInDirectory

func CountFilesInDirectory(dir string) (int, error)

func CreateSignature

func CreateSignature(priv *rsa.PrivateKey, message []byte) (string, error)

Создание цифровой подписи

func DecodePrivateKey

func DecodePrivateKey(encoded string) (*rsa.PrivateKey, error)

Декодирование приватного ключа из Base64

func DecodePublicKey

func DecodePublicKey(encoded string) (*rsa.PublicKey, error)

Декодирование публичного ключа из Base64

func Decrypt

func Decrypt(sk *rsa.PrivateKey, str string) (string, error)

func DecryptAES

func DecryptAES(key []byte, msg AESEncryptedMessage) ([]byte, error)

func EncodePrivateKey

func EncodePrivateKey(priv *rsa.PrivateKey) string

Кодирование приватного ключа в Base64

func EncodePublicKey

func EncodePublicKey(pub *rsa.PublicKey) string

Кодирование публичного ключа в Base64

func Encrypt

func Encrypt(pk *rsa.PublicKey, str []byte) (string, error)

func GenerateKeyPair

func GenerateKeyPair(bits int) (*rsa.PrivateKey, *rsa.PublicKey, error)

Генерация пары ключей RSA

func GenerateRandomString

func GenerateRandomString(length int) (string, error)

func Get

func Get(url string) (string, string, error)

func GetIP

func GetIP(r *http.Request) string

func In

func In(filename string) (string, error)

func Out

func Out(path, str string) error

func OutBytes

func OutBytes(path string, str []byte) error

func Post

func Post(url string, data []byte) (string, string, error)

func Sha

func Sha(message string) string

Принимает строку и возвращает её хеш в виде строки

func StringToB64

func StringToB64(input string) string

EncodeToBase64 кодирует входную строку в Base64.

func VerifySignature

func VerifySignature(pub *rsa.PublicKey, message []byte, signature string) error

Проверка цифровой подписи

Types

type AESEncryptedMessage

type AESEncryptedMessage struct {
	IV      string `json:"iv"`
	Message string `json:"message"`
}

func DecodeAESMessage

func DecodeAESMessage(msg []byte) (AESEncryptedMessage, error)

func EncryptAES

func EncryptAES(key, msg []byte) (AESEncryptedMessage, error)

func (AESEncryptedMessage) EncodeAESMessage

func (msg AESEncryptedMessage) EncodeAESMessage() ([]byte, error)

type EncryptedMessage

type EncryptedMessage struct {
	IV      string `json:"iv"`
	Key     string `json:"key"`
	Message string `json:"message"`
}

func NewEncryptedMessage

func NewEncryptedMessage(jsonStr string) (EncryptedMessage, error)

func (EncryptedMessage) String

func (msg EncryptedMessage) String() (string, error)

Jump to

Keyboard shortcuts

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