##### SUMMARY
With a variable, `test_password` with value `hello`:

{{ test_password | hash('sha1') }} -> works
{{ test_password | hash('sha256') }} -> works
{{ test_password | hash('blowfish') }} -> returns blank
{{ test_password | password_hash('sha512') }} -> only works if the value of `test_password` is not encrypted with ansible-vault.

Detailed code below.

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#hashing-filters

##### ANSIBLE VERSION
```
1)
ansible 2.9.9
  config file = /Users/<redacted>/.ansible.cfg
  configured module search path = ['/Users/<redacted>/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.9.9/libexec/lib/python3.8/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 3.8.2 (default, Mar 11 2020, 14:40:53) [Clang 11.0.0 (clang-1100.0.33.17)]
```

```
2)
ansible 2.9.9
  config file = None
  configured module search path = ['/home/ubuntu/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/ubuntu/.local/lib/python3.6/site-packages/ansible
  executable location = /home/ubuntu/.local/bin/ansible
  python version = 3.6.9 (default, Apr 18 2020, 01:56:04) [GCC 8.4.0]
```

##### CONFIGURATION
```
1)
DEPRECATION_WARNINGS(/Users/<redacted>/.ansible.cfg) = False
```

##### OS / ENVIRONMENT
```
1)
Darwin OSTML0263654 19.4.0 Darwin Kernel Version 19.4.0: Wed Mar  4 22:28:40 PST 2020; root:xnu-6153.101.6~15/RELEASE_X86_64 x86_64
```

```
2)
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"

Linux 4.15.0-1065-aws #69-Ubuntu SMP x86_64 x86_64 x86_64 GNU/Linux
```


##### STEPS TO REPRODUCE
Vault password is `12345`
```
---

- name: Ansible password hash bug report
  connection: local
  gather_facts: false
  hosts: 127.0.0.1
  tasks:

    - name: Assign the value "hello" to test_password (vault password is 12345)
      set_fact:
        test_password: !vault |
              $ANSIBLE_VAULT;1.1;AES256
              39343361653534323234663039376164326564626361353265643438373937366139363434373034
              3966323339316461396131666339316631323236656430350a613764663563636634666132303232
              36386133346337353761343134366236613836366638613962363863626634663937323465636263
              3539353166313439360a343832313938393036346635636131363930353562356331303930626636
              6439

    - debug: msg={{ test_password }}

    - name: Generate sha1 hash
      set_fact:
        test_password_sha1: "{{ test_password | hash('sha1') }}"

    - debug: msg={{ test_password_sha1 }}

    - name: Generate sha256 hash
      set_fact:
        test_password_sha256: "{{ test_password | hash('sha256') }}"

    - debug: msg={{ test_password_sha256 }}

    - name: Generate blowfish hash
      set_fact:
        test_password_blowfish: "{{ test_password | hash('blowfish') }}"

    - debug: msg={{ test_password_blowfish }}

    - name: Generate sha512 password_hash
      set_fact:
        test_password_phash_sha512: "{{ test_password | password_hash('sha512') }}"

    - debug: msg={{ test_password_phash_sha512 }}
```

##### EXPECTED RESULTS
```
PLAY [Ansible password hash bug report] *************************************************************************************************************************************************************************

TASK [Assign the value "hello" to test_password (vault password is 12345)] **************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "hello"
}

TASK [Generate sha1 hash] ***************************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
}

TASK [Generate sha256 hash] *************************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}

TASK [Generate blowfish hash] ***********************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "$2y$08$uzCFDwSh3Vc7DhdmDNEykOxGKmHOxZzOY4LHvXg0hfTUPNa657cia"
}

TASK [Generate sha512 password_hash] ****************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "9B71D224BD62F3785D96D46AD3EA3D73319BFBC2890CAADAE2DFF72519673CA72323C3D99BA5C11D7C7ACC6E14B8C5DA0C4663475C2E5C3ADEF46F73BCDEC043"
}
```


##### ACTUAL RESULTS


```
PLAY [Ansible password hash bug report] *************************************************************************************************************************************************************************

TASK [Assign the value "hello" to test_password (vault password is 12345)] **************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "hello"
}

TASK [Generate sha1 hash] ***************************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d"
}

TASK [Generate sha256 hash] *************************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}

TASK [Generate blowfish hash] ***********************************************************************************************************************************************************************************
ok: [127.0.0.1]

TASK [debug] ****************************************************************************************************************************************************************************************************
ok: [127.0.0.1] => {
    "msg": ""
}

TASK [Generate sha512 password_hash] ****************************************************************************************************************************************************************************
fatal: [127.0.0.1]: FAILED! => {"msg": "Unexpected templating type error occurred on ({{ test_password | password_hash('sha512') }}): secret must be unicode or bytes, not ansible.parsing.yaml.objects.AnsibleVaultEncryptedUnicode"}
```

uuid_namespace = namespace
    if not isinstance(uuid_namespace, uuid.UUID):
        try:
            uuid_namespace = uuid.UUID(namespace)
        except (AttributeError, ValueError) as e:
            raise AnsibleFilterError("Invalid value '%s' for 'namespace': %s" % (to_native(namespace), to_native(e)))
    
    return to_text(uuid.uuid5(uuid_namespace, to_native(string, errors='surrogate_or_strict')))
def mandatory(a, msg=None):
    from jinja2.runtime import Undefined
    ''' Make a variable mandatory '''
    if isinstance(a, Undefined):
        if a._undefined_name is not None:
            name = "'%s' " % to_text(a._undefined_name)
        else:
            name = ''
        if msg is not None:
            raise AnsibleFilterError(to_native(msg))
        else:
            raise AnsibleFilterError("Mandatory variable %s not defined." % name)
    return a
def combine(*terms, **kwargs):