We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 20a3f49 commit 4983f34Copy full SHA for 4983f34
packages/shared/migrations/20250214140307.sql
@@ -2,11 +2,14 @@
2
CREATE OR REPLACE FUNCTION hex_to_sha256(hex_str text, prefix text) RETURNS text AS $$
3
DECLARE
4
bytes bytea;
5
+ base64_hash text;
6
BEGIN
7
-- Remove the prefix and convert remaining hex to bytes
8
bytes := decode(substring(hex_str from length(prefix) + 1), 'hex');
- -- Return SHA256 hash as base64 string
9
- RETURN encode(sha256(bytes), 'base64');
+ -- Get base64 hash and remove padding
10
+ base64_hash := rtrim(encode(sha256(bytes), 'base64'), '=');
11
+ -- Return SHA256 hash with $sha256$ prefix and base64-encoded hash without padding
12
+ RETURN '$sha256$' || base64_hash;
13
END;
14
$$ LANGUAGE plpgsql;
15
0 commit comments