Skip to main content

CryptoApi

Defines cryptographic methods.

Constructors

CryptoApi

Create instance of CryptoApi.

public void CryptoApi()

Methods

close

public void close()

convertPEMKeyToWIFKey

Converts given private key in PEM format to its WIF format.

public String convertPEMKeyToWIFKey(
String pemKey
)

NameTypeDescription
pemKeyStringprivate key to convert

TypeDescription
String Private key in WIF format

decryptDataSymmetric

Decrypts buffer with a given key using AES.

public byte[] decryptDataSymmetric(
byte[] data,
byte[] symmetricKey
)

NameTypeDescription
databyte[]buffer to decrypt
symmetricKeybyte[]key used to decrypt data

TypeDescription
byte[] Plain (decrypted) data buffer

derivePrivateKey

Generates a new private ECC key from a password using pbkdf2.

public String derivePrivateKey(
String password,
String salt
)

NameTypeDescription
passwordStringthe password used to generate the new key
saltStringrandom string (additional input for the hashing function)

TypeDescription
String Generated ECC key in WIF format

derivePublicKey

Generates a new public ECC key as a pair for an existing private key.

public String derivePublicKey(
String privateKey
)

NameTypeDescription
privateKeyStringprivate ECC key in WIF format

TypeDescription
String Generated ECC key in BASE58DER format

encryptDataSymmetric

Encrypts buffer with a given key using AES.

public byte[] encryptDataSymmetric(
byte[] data,
byte[] symmetricKey
)

NameTypeDescription
databyte[]buffer to encrypt
symmetricKeybyte[]key used to encrypt data

TypeDescription
byte[] Encrypted data buffer

generateKeySymmetric

Generates a new symmetric key.

public byte[] generateKeySymmetric()

TypeDescription
byte[] Generated key

generatePrivateKey

Generates a new private ECC key.

public String generatePrivateKey(
String randomSeed
)

NameTypeDescription
randomSeedStringoptional string used as the base to generate the new key

TypeDescription
String Generated ECC key in WIF format

signData

Creates a signature of data using given key.

public byte[] signData(
byte[] data,
String privateKey
)

NameTypeDescription
databyte[]data the buffer to sign
privateKeyStringthe key used to sign data

TypeDescription
byte[] Signature of data

verifySignature

Validate a signature of data using given key.

public boolean verifySignature(
byte[] data,
byte[] signature,
String publicKey
)

NameTypeDescription
databyte[]buffer
signaturebyte[]of data
publicKeyStringpublic ECC key in BASE58DER format used to validate data

TypeDescription
boolean data validation result