PrivMX DOCS
API Reference/PrivMX Endpoint C#/Crypto

CryptoApi

Static Methods

Create

Creates an instance of the CryptoApi.

static CryptoApi Create()

Returns

CryptoApi · Created instance of the CryptoApi.

Methods

SignData

Creates a signature of data using given key.

Params

data

byte[]

Data to sign.

privateKey

string

The private key used to sign data.

byte[] SignData(
byte[] data,
string privateKey
)

Returns

byte[] · Signature of data.

VerifySignature

Verifies a signature of data using given key.

Params

data

byte[]

Signed data.

signature

byte[]

Signature of data.

publicKey

string

The public key used to verify the signature.

bool VerifySignature(
byte[] data,
byte[] signature,
string publicKey
)

Returns

bool · Verification status.

GeneratePrivateKey

Generates a new random private key.

The returned key is private key of elliptic curve cryptography.

Params

randomSeed

string?

(optional) String used as the seed of random generator.

string GeneratePrivateKey(
string? randomSeed = null
)

Returns

string · Generated private key in WIF format.

DerivePrivateKey

Derives a private key from a password and salt.

The returned key is private key of elliptic curve cryptography. PBKDF2 algorithm is used to derive the key.

This method is deprecated. Use CryptoApi.DerivePrivateKey2 method instead.

Params

password

string

The password used to derive from.

salt

string

The random additional data used to derive.

string DerivePrivateKey(
string password,
string salt
)

Returns

string · Derived private key in WIF format.

DerivePrivateKey2

Derives a private key from a password and salt.

The returned key is private key of elliptic curve cryptography. PBKDF2 algorithm is used to derive the key.

Compared to CryptoApi.DerivePrivateKey method, this version of the derive function has an increased number of rounds. This makes using this function a safer choice, but it makes the derived key different than in the previous version.

Params

password

string

The password used to derive from.

salt

string

The random additional data used to derive.

string DerivePrivateKey2(
string password,
string salt
)

Returns

string · Derived private key in WIF format.

DerivePublicKey

Derives public key from a private key.

The returned key is public key of elliptic curve cryptography.

Params

privateKey

string

The private key in WIF format.

string DerivePublicKey(
string privateKey
)

Returns

string · Public key in Base58 format.

GenerateKeySymmetric

Generates a new random key for symmetric cryptography.

byte[] GenerateKeySymmetric()

Returns

byte[] · Generated symmetric key.

EncryptDataSymmetric

Encrypts data using a symmetric key.

AES algorithm is used to encrypt data.

Params

data

byte[]

Data to encrypt.

symmetricKey

byte[]

The symmetric key.

byte[] EncryptDataSymmetric(
byte[] data,
byte[] symmetricKey
)

Returns

byte[] · Encrypted data.

DecryptDataSymmetric

Decrypts data using a symmetric key.

Params

data

byte[]

Data to decrypt.

symmetricKey

byte[]

The symmetric key.

byte[] DecryptDataSymmetric(
byte[] data,
byte[] symmetricKey
)

Returns

byte[] · Decrypted data.

ConvertPEMKeytoWIFKey

Converts a private key in PEM format to WIF format.

Params

pemKey

string

The private key in PEM format.

string ConvertPEMKeytoWIFKey(
string pemKey
)

Returns

string · Converted private key to WIF format.

We use cookies on our website. We use them to ensure the proper functioning of the site and, if you agree, for purposes we set, such as analytics or marketing.