Issue when importing user with custom hash password

I have this JSON file with a user I want to import with a custom hash password:

        "email": "",
        "email_verified": false,
        "name": "",
        "nickname": "testuser",
        "custom_password_hash": {
            "algorithm": "sha512",
            "hash": {
                "value": "e105edc2108424204adda7327a0bb4315a44d2db6eee66caf477cbb69b9fedb19255069894f1c0d62860728e1920ce957e539dc2e7c099467bcef41b661c2ac6",
                "encoding": "hex"
        "salt": {
            "value": "e2edb8665922083b488b477810ccfa0b57d581b6",
            "encoding": "hex",
            "position": "prefix"

This is the code for generating the salt and hashing the password using SHA512 algorithm:

import crypto = require('crypto');
import { SHA512 } from 'crypto-js';
 * Generate a salt for hashing.
 * Creates a random string & convert to a hexadecimal
function genSalt() {
  return crypto.randomBytes(20).toString('hex');

 * Perform a one-way hash of a value with the given salt.
 * @param plaintext
 * @param salt
function hashWithSalt(plaintext: string, salt: string) {
  return SHA512(salt + plaintext).toString();

let salt_str = genSalt();
let hash_pass =   hashWithSalt('Samplepass123', salt_str);


The import is successful. But when I try to log in as this user, I am getting this error:
"Verification failed for the provided custom_password_hash

What am I doing wrong?