crypto

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2023 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package crypto the crypto JS implementation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Md4

func Md4(input any) (any, error)

Md4 returns the MD4 Hash of input in the given encoding.

func Md5

func Md5(input any) (any, error)

Md5 returns the MD5 Hash of input in the given encoding.

func RandomBytes

func RandomBytes(call goja.FunctionCall, vm *goja.Runtime) (ret goja.Value)

RandomBytes returns random data of the given size.

func Ripemd160

func Ripemd160(input any) (any, error)

Ripemd160 returns the RIPEMD160 Hash of input in the given encoding.

func Sha1

func Sha1(input any) (any, error)

Sha1 returns the SHA1 Hash of input in the given encoding.

func Sha256

func Sha256(input any) (any, error)

Sha256 returns the SHA256 Hash of input in the given encoding.

func Sha384

func Sha384(input any) (any, error)

Sha384 returns the SHA384 Hash of input in the given encoding.

func Sha512

func Sha512(input any) (any, error)

Sha512 returns the SHA512 Hash of input in the given encoding.

func Sha512_224

func Sha512_224(input any) (any, error)

Sha512_224 returns the SHA512/224 Hash of input in the given encoding.

func Sha512_256

func Sha512_256(input any) (any, error)

Sha512_256 returns the SHA512/256 Hash of input in the given encoding.

Types

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

Cipher A Block represents an implementation of block cipher using a given key. It provides the capability to encrypt or decrypt individual blocks.

func Aes

func Aes(key, iv any, algorithm string) (*Cipher, error)

Aes returns a new AES cipher

func CreateCipher

func CreateCipher(algorithm string, key, iv any) (*Cipher, error)

CreateCipher returns a new Cipher

func Des

func Des(key, iv any, algorithm string) (*Cipher, error)

Des returns a new DES cipher

func TripleDES

func TripleDES(key, iv any, algorithm string) (*Cipher, error)

TripleDES returns a new TDes cipher

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(input any) (*Encoder, error)

Decrypt decrypts the first block in src into dst.

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(input any) (*Encoder, error)

Encrypt encrypts the first block in src into dst.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder the encoded

func Hash

func Hash(algorithm string, input any) (*Encoder, error)

Hash returns a new Encoder using the given algorithm and key.

func Hmac

func Hmac(algorithm string, key, input any) (*Encoder, error)

Hmac returns a new Encoder of input using the given algorithm and key.

func (*Encoder) Base64

func (e *Encoder) Base64() string

Base64 encode to base64

func (*Encoder) Base64rawurl

func (e *Encoder) Base64rawurl() string

Base64rawurl encode to base64rawurl

func (*Encoder) Base64url

func (e *Encoder) Base64url() string

Base64url encode to base64url

func (*Encoder) Binary

func (e *Encoder) Binary(_ goja.FunctionCall, vm *goja.Runtime) goja.Value

Binary encode to arraybuffer

func (*Encoder) Hex

func (e *Encoder) Hex() string

Hex encode to hex

func (*Encoder) String

func (e *Encoder) String() string

String encode to string

type Hasher

type Hasher struct {
	// contains filtered or unexported fields
}

Hasher wraps a hash.Hash.

func CreateHMAC

func CreateHMAC(algorithm string, key any) (*Hasher, error)

CreateHMAC returns a new HMAC Hash using the given algorithm and key.

func CreateHash

func CreateHash(algorithm string) (*Hasher, error)

CreateHash returns a Hasher instance that uses the given algorithm.

func (*Hasher) Digest

func (hasher *Hasher) Digest() *Encoder

Digest returns the Hash value in the given encoding.

func (*Hasher) Encrypt

func (hasher *Hasher) Encrypt(input any) (*Encoder, error)

Encrypt returns the Encoder.

func (*Hasher) Reset

func (hasher *Hasher) Reset()

Reset resets the Hash value to initial values.

func (*Hasher) Update

func (hasher *Hasher) Update(input any) error

Update the Hash with the input data.

type Module

type Module struct{}

Module js module

func (*Module) Exports

func (*Module) Exports() any

Exports returns module instance

type None

type None struct{}

None padding the blocks size

func (None) Padding

func (None) Padding(data []byte, _ int) []byte

Padding the blocks with bytes

func (None) UnPadding

func (None) UnPadding(data []byte) []byte

UnPadding the data

type PKCS5

type PKCS5 struct{}

PKCS5 padding the blocks size

func (PKCS5) Padding

func (PKCS5) Padding(data []byte, _ int) []byte

Padding the blocks with bytes

func (PKCS5) UnPadding

func (PKCS5) UnPadding(data []byte) []byte

UnPadding the data

type PKCS7

type PKCS7 struct{}

PKCS7 padding the blocks size

func (PKCS7) Padding

func (PKCS7) Padding(data []byte, blockSize int) []byte

Padding the blocks with bytes

func (PKCS7) UnPadding

func (PKCS7) UnPadding(data []byte) []byte

UnPadding the data

type Padding

type Padding interface {
	// Padding the blocks with bytes
	Padding([]byte, int) []byte
	// UnPadding the data
	UnPadding([]byte) []byte
}

Padding the blocks size

type Zero

type Zero struct{}

Zero padding the blocks size

func (Zero) Padding

func (Zero) Padding(data []byte, blockSize int) []byte

Padding the blocks with bytes

func (Zero) UnPadding

func (Zero) UnPadding(data []byte) []byte

UnPadding the data

Jump to

Keyboard shortcuts

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