PHP Classes

File: src/Contract/SymmetricKeyCryptoInterface.php

Recommend this page to a friend!
  Packages of Scott Arciszewski   Halite   src/Contract/SymmetricKeyCryptoInterface.php   Download  
File: src/Contract/SymmetricKeyCryptoInterface.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: Halite
Perform cryptography operations with libsodium
Author: By
Last change: For version 2, let's use strict types!
Date: 10 years ago
Size: 1,608 bytes
 

Contents

Class file image Download
<?php
declare(strict_types=1);
namespace ParagonIE\Halite\Contract;

use \ParagonIE\Halite\Symmetric\{
    AuthenticationKey,
    EncryptionKey
};

/**
 * An interface fundamental to all cryptography implementations
 */
interface SymmetricKeyCryptoInterface
{    
    /**
     * Encrypt a message with a Key
     * 
     * @param string $plaintext
     * @param KeyInterface $secretKey
     * @param boolean $raw Don't hex encode the output?
     */
    public static function encrypt(
        string $plaintext,
        EncryptionKey $secretKey,
        bool $raw = false
    ): string;
    
    /**
     * Decrypt a message with a Key
     * 
     * @param string $ciphertext
     * @param KeyInterface $secretKey
     * @param boolean $raw Don't hex decode the input?
     */
    public static function decrypt(
        string $ciphertext,
        EncryptionKey $secretKey,
        bool $raw = false
    ): string;
    
    /**
     * Authenticate a message, get a message authentication code
     * 
     * @param string $message
     * @param KeyInterface $secretKey
     * @param boolean $raw
     */
    public static function authenticate(
        string $message,
        AuthenticationKey $secretKey,
        bool $raw = false
    ): string;
    
    /**
     * Verify the message authentication code
     * 
     * @param string $message
     * @param KeyInterface $secretKey
     * @param string $mac
     * @param boolean $raw
     */
    public static function verify(
        string $message,
        AuthenticationKey $secretKey,
        string $mac,
        bool $raw = false
    ): bool;
}