Structure
String
@frozen struct String
A Unicode string value that is a collection of characters
Methods
sealAES(senderPrivateKey:recipientPublicKey:salt:)
public func sealAES(senderPrivateKey: P256.KeyAgreement.PrivateKey, recipientPublicKey: P256.KeyAgreement.PublicKey, salt: String) -> String?
Encrypts current string using AES.GCM cipher.
Parameters
Name | Type | Description |
---|---|---|
senderPrivateKey | P256.KeyAgreement.PrivateKey |
Sender private key. |
recipientPublicKey | P256.KeyAgreement.PublicKey |
Recipient public key. |
salt | String |
The salt to use for key derivation. |
Returns
Combined AES Selead box (nonce || ciphertext || tag) coded on base64. If there's a problem encrypting, nil
is retuned.
openAES(recipientPrivateKey:senderPublicKey:salt:)
public func openAES(recipientPrivateKey: P256.KeyAgreement.PrivateKey, senderPublicKey: P256.KeyAgreement.PublicKey, salt: String) -> String?
Decrypts current combined AES Selead box data (nonce || ciphertext || tag) and coded on Base64 using AES.GCM cipher.
Parameters
Name | Type | Description |
---|---|---|
recipientPrivateKey | P256.KeyAgreement.PrivateKey |
Recipient private key. |
senderPublicKey | P256.KeyAgreement.PublicKey |
Sender public key. |
salt | String |
The salt to use for key derivation. |
Returns
Decrypts the message and verifies its authenticity using AES.GCM. If there's a problem decrypting, nil
is retuned.
sealChaChaPoly(senderPrivateKey:recipientPublicKey:salt:)
public func sealChaChaPoly(senderPrivateKey: P256.KeyAgreement.PrivateKey, recipientPublicKey: P256.KeyAgreement.PublicKey, salt: String) -> String?
Encrypts current string using ChaChaPoly cipher.
Parameters
Name | Type | Description |
---|---|---|
senderPrivateKey | P256.KeyAgreement.PrivateKey |
Sender private key. |
recipientPublicKey | P256.KeyAgreement.PublicKey |
Recipient public key. |
salt | String |
The salt to use for key derivation. |
Returns
Combined ChaChaPoly Selead box (nonce || ciphertext || tag) coded on base64. If there's a problem encrypting, nil
is retuned.
openChaChaPoly(recipientPrivateKey:senderPublicKey:salt:)
public func openChaChaPoly(recipientPrivateKey: P256.KeyAgreement.PrivateKey, senderPublicKey: P256.KeyAgreement.PublicKey, salt: String) -> String?
Decrypts current combined ChaChaPoly Selead box data (nonce || ciphertext || tag) and coded on Base64 using ChaChaPoly cipher.
Parameters
Name | Type | Description |
---|---|---|
recipientPrivateKey | P256.KeyAgreement.PrivateKey |
Recipient private key. |
senderPublicKey | P256.KeyAgreement.PublicKey |
Sender public key. |
salt | String |
The salt to use for key derivation. |
Returns
Decrypts the message and verifies its authenticity using ChaChaPoly. If there's a problem decrypting, nil
is retuned.
authenticationCodeHMAC(senderPrivateKey:recipientPublicKey:salt:)
public func authenticationCodeHMAC(senderPrivateKey: P256.KeyAgreement.PrivateKey, recipientPublicKey: P256.KeyAgreement.PublicKey, salt: String) -> String?
Computes a message authentication code for the given data using HMAC from current string.
Parameters
Name | Type | Description |
---|---|---|
senderPrivateKey | P256.KeyAgreement.PrivateKey |
Sender private key. |
recipientPublicKey | P256.KeyAgreement.PublicKey |
Recipient public key. |
salt | String |
The salt to use for key derivation. |
Returns
Message authentication code coded on Base64. If there's a problem computing, nil
is retuned.
isValidAuthenticationCodeHMAC(recipientPrivateKey:authenticationCode:senderPublicKey:salt:)
public func isValidAuthenticationCodeHMAC(recipientPrivateKey: P256.KeyAgreement.PrivateKey, authenticationCode: String, senderPublicKey: P256.KeyAgreement.PublicKey, salt: String) -> Bool
Returns a Boolean indicating whether the given code is valid for current string using HMAC.
Parameters
Name | Type | Description |
---|---|---|
recipientPrivateKey | P256.KeyAgreement.PrivateKey |
Recipient private key. |
authenticationCode | String |
authentication code to validate coded on Base64. |
senderPublicKey | P256.KeyAgreement.PublicKey |
Sender public key. |
salt | String |
The salt to use for key derivation. |
Returns
Boolean indicating whether the given code is valid for current data. If there's a problem validating, false
is retuned.