crypto

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 23 Imported by: 0

README

xk6-crypto

A k6 extension for using extended crypto functions, mostly from golang.org/x/crypto.

Built for k6 using xk6.

This project is fork from https://github.com/szkiba/xk6-crypto and further support will take place in this repository

Usage

Import an entire module's contents:

import * as xcrypto from "k6/x/crypto";

Import a single export from a module:

import { hkdf } from "k6/x/crypto";

API

Functions:

For complete API documentation click here!

Build

To build a k6 binary with this extension, first ensure you have the prerequisites:

Then:

  1. Install xk6:
$ go install go.k6.io/xk6/cmd/xk6@latest
  1. Build the binary:
$ xk6 build --with github.com/bvpatel/xk6-crypto@latest

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnsupportedHash      = errors.New("unsupported hash")
	ErrInvalidKeyLen        = errors.New("invalid keylen")
	ErrUnsupportedAlgorithm = errors.New("unsupported algorithm")
)

Functions

This section is empty.

Types

type Crypto

type Crypto struct{}

func New

func New() *Crypto

func (*Crypto) Ecdh

func (c *Crypto) Ecdh(ctx context.Context, algorithm string, privateKey, publicKey goja.ArrayBuffer) (interface{}, error)

func (*Crypto) GenerateKeyPair

func (c *Crypto) GenerateKeyPair(ctx context.Context, algorithm string, seedIn interface{}) (*KeyPair, error)

func (*Crypto) Hkdf

func (c *Crypto) Hkdf(ctx context.Context, hash string, secretIn, saltIn, infoIn interface{}, keylen int) (interface{}, error)

func (*Crypto) Pbkdf2

func (c *Crypto) Pbkdf2(ctx context.Context, passwordIn, saltIn interface{}, iter, keylen int, hash string) (interface{}, error)

func (*Crypto) RsaEncryptOAEP

func (c *Crypto) RsaEncryptOAEP(ctx context.Context, publicKey string, encryptData string, hash string) (string, error)

func (*Crypto) RsaPublicEncryptWithBase64PublicKey

func (c *Crypto) RsaPublicEncryptWithBase64PublicKey(ctx context.Context, publicKey string, encryptData string) (string, error)

func (*Crypto) RsaPublicEncryptWithPublicKey

func (c *Crypto) RsaPublicEncryptWithPublicKey(ctx context.Context, publicKey string, encryptData string) (string, error)

type KeyPair

type KeyPair struct {
	PrivateKey goja.ArrayBuffer `js:"privateKey"`
	PublicKey  goja.ArrayBuffer `js:"publicKey"`
}

Jump to

Keyboard shortcuts

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