You are here

public static function ParagonIE_Sodium_Core_HChaCha20::hChaCha20 in Automatic Updates 7

Same name and namespace in other branches
  1. 8 vendor/paragonie/sodium_compat/src/Core/HChaCha20.php \ParagonIE_Sodium_Core_HChaCha20::hChaCha20()

Parameters

string $in:

string $key:

string|null $c:

Return value

string

Throws

TypeError

9 calls to ParagonIE_Sodium_Core_HChaCha20::hChaCha20()
ParagonIE_Sodium_Core_XChaCha20::ietfStream in vendor/paragonie/sodium_compat/src/Core/XChaCha20.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core_XChaCha20::ietfStreamXorIc in vendor/paragonie/sodium_compat/src/Core/XChaCha20.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core_XChaCha20::stream in vendor/paragonie/sodium_compat/src/Core/XChaCha20.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Core_XChaCha20::streamXorIc in vendor/paragonie/sodium_compat/src/Core/XChaCha20.php
@internal You should not use this directly from another application
ParagonIE_Sodium_Crypto::aead_xchacha20poly1305_ietf_decrypt in vendor/paragonie/sodium_compat/src/Crypto.php
AEAD Decryption with ChaCha20-Poly1305, IETF mode (96-bit nonce)

... See full list

File

vendor/paragonie/sodium_compat/src/Core/HChaCha20.php, line 19

Class

ParagonIE_Sodium_Core_HChaCha20
Class ParagonIE_Sodium_Core_HChaCha20

Code

public static function hChaCha20($in = '', $key = '', $c = null) {
  $ctx = array();
  if ($c === null) {
    $ctx[0] = 0x61707865;
    $ctx[1] = 0x3320646e;
    $ctx[2] = 0x79622d32;
    $ctx[3] = 0x6b206574;
  }
  else {
    $ctx[0] = self::load_4(self::substr($c, 0, 4));
    $ctx[1] = self::load_4(self::substr($c, 4, 4));
    $ctx[2] = self::load_4(self::substr($c, 8, 4));
    $ctx[3] = self::load_4(self::substr($c, 12, 4));
  }
  $ctx[4] = self::load_4(self::substr($key, 0, 4));
  $ctx[5] = self::load_4(self::substr($key, 4, 4));
  $ctx[6] = self::load_4(self::substr($key, 8, 4));
  $ctx[7] = self::load_4(self::substr($key, 12, 4));
  $ctx[8] = self::load_4(self::substr($key, 16, 4));
  $ctx[9] = self::load_4(self::substr($key, 20, 4));
  $ctx[10] = self::load_4(self::substr($key, 24, 4));
  $ctx[11] = self::load_4(self::substr($key, 28, 4));
  $ctx[12] = self::load_4(self::substr($in, 0, 4));
  $ctx[13] = self::load_4(self::substr($in, 4, 4));
  $ctx[14] = self::load_4(self::substr($in, 8, 4));
  $ctx[15] = self::load_4(self::substr($in, 12, 4));
  return self::hChaCha20Bytes($ctx);
}