In making downloaded Oracle implementation SHA256 encryption code,
In encrypt English letters and Numbers are correct, but encryption Chinese characters, can appear the result error
Find a reason in the afternoon, I do not know why
To help you
The following is to call the main function:
The CREATE OR REPLACE PACKAGE BODY SHA256 IS
.
The FUNCTION ENCRYPT IN VARCHAR2 (x) RETURN VARCHAR2 AS
CTX TR_CTX;
Res TA_NUMBER;
The BEGIN
RETURN ENCRYPT_RAW (utl_raw cast_to_raw (x));
END;
The FUNCTION ENCRYPT_RAW (x) IN RAW RETURN VARCHAR2 AS
CTX TR_CTX;
Res TA_NUMBER;
The BEGIN
Sha256_init_ctx (CTX);
Sha256_process_bytes (x, utl_raw length (x), CTX);
Sha256_finish_ctx (CTX, res);
RETURN
To_char (res (0), 'FM0xxxxxxx') | |
To_char (res (1), 'FM0xxxxxxx') | |
To_char (res (2), 'FM0xxxxxxx') | |
To_char (res (3), 'FM0xxxxxxx') | |
To_char (res (4), 'FM0xxxxxxx') | |
To_char (res (5), 'FM0xxxxxxx') | |
To_char (res (6), 'FM0xxxxxxx') | |
To_char (res (7), 'FM0xxxxxxx');
END;