How to convert plain text to SHA-256 hash in Netezza? - hash

Can anyone please help me with some sql query where I can convert plain text to SHA-256 hash in Netezza..
Thanks in advance..

The docs show that this is simply calling the hash function with the second argument equal to 2.
select hash('string', 2)
But I'm presuming you'd like it in hexadecimal format, so wrap it in rawtohex.
select rawtohex(hash('string', 2))

Related

How to enter in a unicode character code in BigQuery?

Let's say I want to use the character 倀:
https://www.fileformat.info/info/unicode/char/20480/index.htm
How would I type this into a query in BigQuery with the proper escape sequence? My thought was the following, but this seems like it's not correct based on the Lexical Structure:
SELECT '倀', '\U00020480'
But obviously that's not correct as I'm getting:
How would I properly type it in with the escape code?
Consider below "hint"
SELECT '倀', CODE_POINTS_TO_STRING([00020480])
with output

How to convert a field to spaces blindly

I have a delimited sequential file. This file has a field that is variable length. I want to make this field blank. Can some suggest how to convert the field to spaces?
Thanks in advance for any help.
The easiest way is this expression in a Transformer stage
Space(Len(InLink.MyString))

What is this hash algorithm?

Being a pentester, I have encountered a hash divided in two parts (the first one probably being the salt) seemingly encoded in Base64 but I am unable to find out the encryption type.
The input that gave me this hash is the string "password". Is anybody able to give me a hint ?
67Wm8zeMSS0=
s9bD0QOa7A6THDMLa39+3LmXgcxzUFdmszeZdlTUzjY=
Thanks in advance
Maybe it's SHA-256 encoded (or any other 256 bit hash algorithm), because if you base64 decode it and hex encode you get:
ebb5a6f3378c492d
b3d6c3d1039aec0e931c330b6b7f7edcb99781cc73505766b337997654d4ce36
The first has an length of 16 and the second a length of 64. That's probably not a coincidence.
Edit: Maybe it's hashed multiple times; an iterated hash. As this post says it is better to decompile the software.

How to get one byte char from byte in postgresql query?

I interested in how to write char in query by the unicode index or byte format(0x27)
So want to get something like that
COPY test_table FROM '/tmp/tests/test.csv' WITH DELIMITER '0x27' CSV
The real need is to insert CSV into postgres with unprintable delimiter
But if it is not possible to use unprintable symbols in COPY... query, i would like to know anyway is it possible to write char by byte difinition, like in example or near that?
Yea, i read documentation, but didint find any examples, and i was searching for answer in many places
You can specify any character using extended string literals and UNICODE escapes:
... DELIMITER E'\u001B'
See the documentation for details.

Does the string functions in DB2 work on a limited ASCII character set?

In a program I have used a function RPAD() to format data coming from DB2 db.
In one instance the value was Ãmber. The following function:
RPAD('Ãmber',10,' ')
gives 9 characters only.
The ASCII value of 'Ã' is 195. I am not able to understand the reason for this behaviour.
Could someone share their experience.
Thanks
By default, DB2 will consider the length of à to be 2, likely because it is counting bytes rather than characters.
values(LENGTH('Ãmber'))
6
You can override it for LENGTH and many other functions
values(LENGTH('Ãmber', CODEUNITS16))
5
Unfortunately, RPAD does not take a parameter like this. I'm guessing this might be because the function was added for Oracle compatibility rather than on its own merits.
You could write your own RPAD function as a stored procedure or UDF, or just handle it with a CASE statement if this is the only place where you need it.