original_string: function encrypt(PersonalData $data, CryptographicDetails $crypto): EncryptedPersonalData {
  
          if ( ! $crypto->encryption() == 'libsodium') {
              throw new CryptographicDetailsNotCompatibleWithEncryption("{$crypto->encryption()} received, expected 'libsodium'");
          }
  
          $dataString = $data->toString();
          $secretKey  = $crypto->key('secretKey');
          $nonce      = $crypto->key('nonce');
  
          $encrypted = sodium_crypto_secretbox($dataString, $nonce, $secretKey);
  
          return EncryptedPersonalData::fromString($encrypted);
      }
code: function encrypt(PersonalData $data, CryptographicDetails $crypto): EncryptedPersonalData {
  
          if ( ! $crypto->encryption() == 'libsodium') {
              throw new CryptographicDetailsNotCompatibleWithEncryption("{$crypto->encryption()} received, expected 'libsodium'");
          }
  
          $dataString = $data->toString();
          $secretKey  = $crypto->key('secretKey');
          $nonce      = $crypto->key('nonce');
  
          $encrypted = sodium_crypto_secretbox($dataString, $nonce, $secretKey);
  
          return EncryptedPersonalData::fromString($encrypted);
      }
code_tokens: function encrypt ( PersonalData $ data , CryptographicDetails $ crypto ) : EncryptedPersonalData { if ( ! $ crypto -> encryption ( ) == 'libsodium' ) { throw new CryptographicDetailsNotCompatibleWithEncryption ( "{$crypto->encryption()} received, expected 'libsodium'" ) ; } $ dataString = $ data -> toString ( ) ; $ secretKey = $ crypto -> key ( 'secretKey' ) ; $ nonce = $ crypto -> key ( 'nonce' ) ; $ encrypted = sodium_crypto_secretbox ( $ dataString , $ nonce , $ secretKey ) ; return EncryptedPersonalData :: fromString ( $ encrypted ) ; }
docstring: encrypt personal data and return an encrypted form
  
  @param PersonalData $data
  @param CryptographicDetails $crypto
  @throws CryptographicDetailsDoNotContainKey
  @throws CryptographicDetailsNotCompatibleWithEncryption
  @return EncryptedPersonalData
docstring_tokens: encrypt personal data and return an encrypted form