• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aplus-framework / crypto / 12003099846

23 Aug 2024 08:22PM UTC coverage: 100.0%. Remained the same
12003099846

push

github

natanfelles
Upgrade coding standard

132 of 132 relevant lines covered (100.0%)

1.85 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/BoxSeal.php
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of Aplus Framework Crypto Library.
4
 *
5
 * (c) Natan Felles <natanfelles@gmail.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Framework\Crypto;
11

12
use SensitiveParameter;
13
use SodiumException;
14

15
/**
16
 * Class BoxSeal.
17
 *
18
 * @package crypto
19
 */
20
class BoxSeal
21
{
22
    use BoxTrait;
23

24
    /**
25
     * Encrypts a message with an anonymous public key.
26
     *
27
     * @param string $message
28
     * @param string $publicKey
29
     *
30
     * @see BoxTrait::makePublicKey()
31
     *
32
     * @throws SodiumException
33
     *
34
     * @return string
35
     */
36
    public static function encrypt(
37
        #[SensitiveParameter]
38
        string $message,
39
        #[SensitiveParameter]
40
        string $publicKey
41
    ) : string {
42
        return \sodium_crypto_box_seal($message, $publicKey);
1✔
43
    }
44

45
    /**
46
     * Decrypts a message ciphertext.
47
     *
48
     * @param string $ciphertext
49
     * @param string $keyPair
50
     *
51
     * @see BoxTrait::makeKeyPair()
52
     *
53
     * @throws SodiumException
54
     *
55
     * @return false|string The message or false if the ciphertext could not be
56
     * decrypted
57
     */
58
    public static function decrypt(
59
        #[SensitiveParameter]
60
        string $ciphertext,
61
        #[SensitiveParameter]
62
        string $keyPair
63
    ) : false | string {
64
        return \sodium_crypto_box_seal_open($ciphertext, $keyPair);
1✔
65
    }
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc