Class CryptoApi
public class CryptoApi : ICryptoApi
- Inheritance
-
CryptoApi
- Implements
- Inherited Members
Methods
ConvertPEMKeytoWIFKey(byte[])
Converts a private key in PEM format to WIF format.
public byte[] ConvertPEMKeytoWIFKey(byte[] pemKey)
Parameters
pemKeybyte[]The private key in PEM format.
Returns
- byte[]
Converted private key to WIF format.
Create()
Creates an instance of the CryptoApi.
public static CryptoApi Create()
Returns
DecryptDataSymmetric(byte[], byte[])
Decrypts data using a symmetric key.
public byte[] DecryptDataSymmetric(byte[] data, byte[] symmetricKey)
Parameters
Returns
- byte[]
Decrypted data.
DerivePrivateKey(byte[], byte[])
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 DerivePrivateKey2(byte[], byte[]) method instead.
[Obsolete("Use CryptoApi.DerivePrivateKey2() instead")]
public byte[] DerivePrivateKey(byte[] password, byte[] salt)
Parameters
passwordbyte[]The password used to derive from.
saltbyte[]The random additional data used to derive.
Returns
- byte[]
Derived private key in WIF format.
DerivePrivateKey2(byte[], byte[])
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 DerivePrivateKey(byte[], byte[]) 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.
public byte[] DerivePrivateKey2(byte[] password, byte[] salt)
Parameters
passwordbyte[]The password used to derive from.
saltbyte[]The random additional data used to derive.
Returns
- byte[]
Derived private key in WIF format.
DerivePublicKey(byte[])
Derives public key from a private key.
The returned key is public key of elliptic curve cryptography.
public string DerivePublicKey(byte[] privateKey)
Parameters
privateKeybyte[]The private key in WIF format.
Returns
- string
Public key in Base58 format.
EncryptDataSymmetric(byte[], byte[])
Encrypts data using a symmetric key.
AES algorithm is used to encrypt data.
public byte[] EncryptDataSymmetric(byte[] data, byte[] symmetricKey)
Parameters
Returns
- byte[]
Encrypted data.
~CryptoApi()
protected ~CryptoApi()
GenerateKeySymmetric()
Generates a new random key for symmetric cryptography.
public byte[] GenerateKeySymmetric()
Returns
- byte[]
Generated symmetric key.
GeneratePrivateKey(byte[]?)
Generates a new random private key.
The returned key is private key of elliptic curve cryptography.
public byte[] GeneratePrivateKey(byte[]? randomSeed = null)
Parameters
randomSeedbyte[](optional) String used as the seed of random generator.
Returns
- byte[]
Generated private key in WIF format.
SignData(byte[], byte[])
Creates a signature of data using given key.
public byte[] SignData(byte[] data, byte[] privateKey)
Parameters
Returns
- byte[]
Signature of data.
VerifySignature(byte[], byte[], string)
Verifies a signature of data using given key.
public bool VerifySignature(byte[] data, byte[] signature, string publicKey)
Parameters
databyte[]Signed data.
signaturebyte[]Signature of data.
publicKeystringThe public key used to verify the signature.
Returns
- bool
Verification status.