Documentation ¶
Overview ¶
Package debounce provides a debouncer func. The most typical use case would be the user typing a text into a form; the UI needs an update, but let's wait for a break.
Index ¶
- func AESCBCDecrypt(key []byte, text string) (string, error)
- func AESCBCDecryptRaw(key []byte, decodedMsg []byte) (string, error)
- func AESCBCDecryptSafety(key []byte, text string) (string, error)
- func AESCBCEncrypt(key []byte, text string) (string, error)
- func AESCBCEncryptRaw(key []byte, text string) ([]byte, error)
- func AESCBCEncryptSafety(key []byte, text string) (string, error)
- func AESCTRDecrypt(encryptData []byte, key []byte) ([]byte, error)
- func AESCTRDecryptWithBase64(encryptDataStr string, key []byte) (string, error)
- func AESCTREncrypt(plainText []byte, key []byte) ([]byte, error)
- func AESCTREncryptWithBase64(plainText []byte, key []byte) (string, error)
- func AESMACDecryptBytes(bytesIn []byte, passphrase string) (decrypted bool, plaintextBytes []byte, err error)
- func AESMACDecryptBytesSafety(bytesIn []byte, passphrase string) (decrypted bool, plaintextBytes []byte, err error)
- func AESMACEncryptBytes(bytesIn []byte, passphrase string) []byte
- func AESMACEncryptBytesSafety(bytesIn []byte, passphrase string) string
- func Base64DecodeBytesToBytes(input []byte) ([]byte, error)
- func Base64DecodeStrToBytes(input string) ([]byte, error)
- func Base64DecodeStrToStr(input string) (string, error)
- func Base64EncodeBytesToStr(input []byte) string
- func Base64EncodeStrToStr(input string) string
- func Base64SafetyDecode(data string) ([]byte, error)
- func Base64SafetyEncode(text string) string
- func Check(e error)
- func CheckURL(urlStr string) error
- func CreateDirectoryIfNotExists(filePath, filename string) (string, error)
- func CurrentDir() string
- func CurrentFile() string
- func Debounce(after time.Duration) func(f func())
- func DeleteRSAKeyPair(path string) error
- func FileExists(fileName string) (bool, error)
- func FileSHA256(filePath string) (string, error)
- func GenerateRSAKeypair(keySize int) (*rsa.PrivateKey, *rsa.PublicKey, error)
- func GenerateRSAKeypairPEM(keySize int, rsaPrivateKeyPassword string) (privKeyPEM *bytes.Buffer, encryptedPrivKeyPEMBase64 string, ...)
- func GetMachineID() string
- func GetMachineIDUseSHA256() string
- func GetSha1Str(str string) string
- func GetSha256Str(str string) string
- func MakeDirIfNotExist(path string)
- func PassphraseToHash(pass string) (string, []byte)
- func PemEncodeRSAPrivateKey(privKey *rsa.PrivateKey, rsaPrivateKeyPassword string) (privKeyPEM *bytes.Buffer, encryptedPrivKeyPEMBase64 string)
- func PemEncodeRSAPublicKey(caPubKey *rsa.PublicKey) (*bytes.Buffer, error)
- func PemToEncryptedBytes(pem *bytes.Buffer, passphrase string) (b *bytes.Buffer)
- func ReadFileToBytes(path string) ([]byte, error)
- func RsaDecrypt(cipherText, keyBytes []byte) []byte
- func RsaDecryptWithSha1Base64(encryptedData, privateKey string) (string, error)
- func RsaEncrypt(data, keyBytes []byte) []byte
- func RsaEncryptWithSha1Base64(originalData, publicKey string) (string, error)
- func RsaSignWithSha1Hex(data string, prvKey string) (string, error)
- func RsaSignWithSha1HexPkcs1(data string, pkcs1keyStr string) ([]byte, error)
- func RsaSignWithSha256(data []byte, keyBytes []byte) []byte
- func RsaVerySignWithSha1Base64(originalData, signData, pubKey string) error
- func RsaVerySignWithSha256(data, signData, keyBytes []byte) bool
- func WriteByteFile(path string, content []byte, mode int, overwrite bool) (bool, error)
- func WriteKeyFile(pem *bytes.Buffer, path string, permission int) (bool, error)
- func WriteRSAKeyPair(privKey *bytes.Buffer, pubKey *bytes.Buffer, path string) (bool, bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AESCTRDecrypt ¶
AESCTREncrypt AES-CTR Decrypt
func AESCTRDecryptWithBase64 ¶
AESCTRDecryptWithBase64 AES-CTR Decrypt
func AESCTREncrypt ¶
AESCTREncrypt AES-CTR Encrypt
func AESCTREncryptWithBase64 ¶
AESCTREncryptWithBase64 AES-CTR Encrypt
func AESMACDecryptBytes ¶
func AESMACDecryptBytes(bytesIn []byte, passphrase string) (decrypted bool, plaintextBytes []byte, err error)
AESMACDecryptBytes takes in a byte slice from a file and a passphrase then returns if the encrypted byte slice was decrypted, if so the plaintext contents, and any errors
func AESMACDecryptBytesSafety ¶
func AESMACDecryptBytesSafety(bytesIn []byte, passphrase string) (decrypted bool, plaintextBytes []byte, err error)
AESMACDecryptBytesSafety takes in a byte slice from a file and a passphrase then returns if the encrypted byte slice was decrypted, if so the plaintext contents, and any errors
func AESMACEncryptBytes ¶
AESMACEncryptBytes is a function that takes a plain byte slice and a passphrase and returns an encrypted byte slice
func AESMACEncryptBytesSafety ¶
AESMACEncryptBytesSafety is a function that takes a plain byte slice and a passphrase and returns an encrypted byte slice
func Base64DecodeBytesToBytes ¶
Base64DecodeBytesToStr converts a Base64 byte slice to a Base64 Decoded Byte slice
func Base64DecodeStrToBytes ¶
Base64DecodeStrToBytes converts a Base64 string to a Base64 Decoded Byte slice
func Base64DecodeStrToStr ¶
Base64DecodeStrToStr converts a Base64 string to a Base64 Decoded String
func Base64EncodeBytesToStr ¶
Base64EncodeBytesToStr converts a byte slice to a Base64 Encoded String
func Base64EncodeStrToStr ¶
Base64EncodeStrToStr converts a string to a Base64 Encoded String
func CreateDirectoryIfNotExists ¶ added in v0.1.6
CreateDirectoryIfNotExists This function, CreateDirectoryIfNotExists(filePath, filename string) (string, error), takes two string arguments, filePath and filename. The function first checks if the given filePath contains a filename. If it does not, it means that the provided filePath is a directory, and the function appends the filename to the path. Next, the function extracts the directory in which the file is located and checks if the directory exists. If the directory does not exist, it creates a new directory. Finally, the function returns the updated file path.
func CurrentDir ¶
func CurrentDir() string
CurrentDir get the directory of the current executable file
func Debounce ¶
New returns a debounced function that takes another functions as its argument. This function will be called when the debounced function stops being called for the given duration. The debounced function can be invoked with different functions, if needed, the last one will win.
func DeleteRSAKeyPair ¶
DeleteRSAKeyPair delete key pair files
func FileExists ¶
FileExists checks if a file exists and returns a boolean or an error
func FileSHA256 ¶
FileSHA256 The sha256 hash of the file
func GenerateRSAKeypair ¶
GenerateRSAKeypair returns a private RSA key pair object
func GenerateRSAKeypairPEM ¶
func GetMachineID ¶
func GetMachineID() string
func GetMachineIDUseSHA256 ¶
func GetMachineIDUseSHA256() string
func GetSha1Str ¶
func GetSha256Str ¶
func MakeDirIfNotExist ¶
func MakeDirIfNotExist(path string)
MakeDirIfNotExist create if the folder does not exist
func PassphraseToHash ¶
PassphraseToHash returns a hexadecimal string of an SHA1 checksumed passphrase
func PemEncodeRSAPrivateKey ¶
func PemEncodeRSAPrivateKey(privKey *rsa.PrivateKey, rsaPrivateKeyPassword string) (privKeyPEM *bytes.Buffer, encryptedPrivKeyPEMBase64 string)
PemEncodeRSAPrivateKey creates a PEM from an RSA Private key, and optionally returns an encrypted version
func PemEncodeRSAPublicKey ¶
PemEncodeRSAPublicKey takes a DER formatted RSA Public Key object and converts it to PEM format
func PemToEncryptedBytes ¶
PemToEncryptedBytes takes a PEM byte buffer and encrypts it
func ReadFileToBytes ¶
ReadFileToBytes will return the contents of a file as a byte slice
func RsaDecryptWithSha1Base64 ¶
RsaDecryptWithSha1Base64 解密:对采用sha1算法加密后转base64格式的数据进行解密(私钥PKCS1格式)
func RsaEncryptWithSha1Base64 ¶
RsaEncryptWithSha1Base64 加密:采用sha1算法加密后转base64格式
func RsaSignWithSha1Hex ¶
RsaSignWithSha1Hex 签名:采用sha1算法进行签名并输出为hex格式(私钥PKCS8格式)
func RsaSignWithSha1HexPkcs1 ¶
RsaSignWithSha1HexPkcs1 签名:采用sha1算法进行签名并输出为hex格式(私钥PKCS1格式)
func RsaSignWithSha256 ¶
RsaSignWithSha256
func RsaVerySignWithSha1Base64 ¶
RsaVerySignWithSha1Base64 验签:对采用sha1算法进行签名后转base64格式的数据进行验签
func RsaVerySignWithSha256 ¶
RsaVerySignWithSha256
func WriteByteFile ¶
WriteByteFile creates a file from a byte slice with an optional file mode, only if it's new, and populates it - can force overwrite optionally
func WriteKeyFile ¶
WriteKeyFile writes a public or private key file depending on the permissions, 644 for public, 400 for private
Types ¶
This section is empty.