Skip to content

Instantly share code, notes, and snippets.

function encryptData($data) {
$plainText = json_encode($data);
$bytesToBeEncrypted = $plainText;
$passwordBytes = utf8_encode("p@SSword");
$passwordBytes = hash('sha256', $passwordBytes, true);
$saltBytes = array(1,2,3,4,5,6,7,8);
$saltBytesstring = "";
<?php
namespace Drupal\projects\Plugin\Block;
use Drupal\Component\Serialization\Json;
use Drupal\Core\Block\Annotation\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
@vistar
vistar / d9-remove-wrong-equal-translations-l10n.md
Last active April 23, 2022 15:54 — forked from JPustkuchen/d8-remove-wrong-equal-translations-l10n.md
Drupal 9 CMS: Delete equal customized translation (source language string = target language string)

Drupal 9 CMS: Delete equal customized translation (source language string = target language string)

If you should encounter the problem that some translations are wrongly translated with the equal source language string (for example in our case there were German translations for "Author" translated with "Author" or "Published" with "Published"), you may use the following snippet to list them.

SELECT s.lid,s.source, t.translation FROM `locales_source` s
INNER JOIN locales_target t
WHERE s.lid=t.lid AND CONVERT(s.source USING utf8) = CONVERT(t.translation USING utf8) 
AND t.customized=1

To finally delete them, you may use something like this, but make a backup before and know what you're doing!