EncryptionUtils
@human-protocol/sdk / encryption / EncryptionUtils
Class: EncryptionUtils
Defined in: encryption.ts:290
Introduction
Utility class for encryption-related operations.
Installation
npm
npm install @human-protocol/sdkyarn
yarn install @human-protocol/sdkCode example
import { EncryptionUtils } from '@human-protocol/sdk';
const keyPair = await EncryptionUtils.generateKeyPair('Human', '[email protected]');Constructors
new EncryptionUtils()
new EncryptionUtils():
EncryptionUtils
Returns
Methods
encrypt()
staticencrypt(message,publicKeys):Promise<string>
Defined in: encryption.ts:444
This function encrypts a message using the specified public keys.
Parameters
message
MessageDataType
Message to encrypt.
publicKeys
string[]
Array of public keys to use for encryption.
Returns
Promise<string>
Message encrypted.
Code example
generateKeyPair()
staticgenerateKeyPair(name,passphrase):Promise<IKeyPair>
Defined in: encryption.ts:382
This function generates a key pair for encryption and decryption.
Parameters
name
string
Name for the key pair.
string
Email for the key pair.
passphrase
string = ''
Passphrase to encrypt the private key. Optional.
Returns
Promise<IKeyPair>
Key pair generated.
Code example
getSignedData()
staticgetSignedData(message):Promise<string>
Defined in: encryption.ts:351
This function gets signed data from a signed message.
Parameters
message
string
Message.
Returns
Promise<string>
Signed data.
Code example
isEncrypted()
staticisEncrypted(message):boolean
Defined in: encryption.ts:494
Verifies if a message appears to be encrypted with OpenPGP.
Parameters
message
string
Message to verify.
Returns
boolean
true if the message appears to be encrypted, false if not.
Code example:
verify()
staticverify(message,publicKey):Promise<boolean>
Defined in: encryption.ts:318
This function verifies the signature of a signed message using the public key.
Parameters
message
string
Message to verify.
publicKey
string
Public key to verify that the message was signed by a specific source.
Returns
Promise<boolean>
True if verified. False if not verified.
Code example
Last updated