Search code examples
salt-cryptographyutf-16

Encrypt a password using Salt UTF-16


I need to encrypt a password using salt and it must be UTF 16.

This is what i have at the moment but they told me its UTF-8

$key = 'dfs7dsfsdf';
$timestamp = '201705111500';
$concat = $key . $timestamp;
$hash = hash('sha256', $concat);

Solution

  • Try this

    $key = 'dfs7dsfsdf';
    $timestamp = '201705111500';
    $concat = $key . $timestamp;
    $cString = mb_convert_encoding($total, "UTF-16LE");
    $hash = hash('sha256', $cString);
    

    You forgot

    $cString = mb_convert_encoding($total, "UTF-16LE");