invalid byte sequence for encoding "UTF8": 0x95-while using PGP Encryption -PostgreSQL

Started by Chaitanya bodlapatiabout 6 years ago3 messageshackers
Jump to latest
#1Chaitanya bodlapati
chaitanya.bodlapati4330@gmail.com

Hi,

I was working on Asymmetric encryption in postgres using pgcrypto . I have
generated the keys and stored in data folder and had inserted the data
using pgcrypto encrypt function .

here the problem comes, I was trying to decrypt the data but it was
throwing me the below error

ERROR: invalid byte sequence for encoding "UTF8": 0x95

Please find the below process which I followed

Generated the keys :
CREATE EXTENSION pgcrypto;

$ gpg --list-keys
/home/ec2-user/.gnupg/pubring.gpg
--------------------------------

pub 2048R/8GGGFF 2020-03-19
uid [ultimate] postgres
sub 2048R/GGGFF7 2020-03-19

create table users(username varchar(100),id integer,ssn bytea);

postgres=# INSERT INTO users
VALUES('randomname',7,pgp_pub_encrypt('434-88-8880',dearmor(pg_read_file('keys/public.key'))));

INSERT 0 1

postgres=# SELECT
pgp_pub_decrypt(ssn,dearmor(pg_read_file('keys/private.key'))) AS mydata
FROM users;

ERROR: invalid byte sequence for encoding "UTF8": 0x95

postgres=# show client_encoding;
client_encoding
-----------------
UTF8
(1 row)

postgres=# show server_encoding;
server_encoding
-----------------
UTF8
(1 row)

Can anyone please help me on this , I am not sure why I was getting this
error.

#2Chaitanya bodlapati
chaitanya.bodlapati4330@gmail.com
In reply to: Chaitanya bodlapati (#1)
Fwd: invalid byte sequence for encoding "UTF8": 0x95-while using PGP Encryption -PostgreSQL

Hi,

I was working on Asymmetric encryption in postgres using pgcrypto . I have
generated the keys and stored in data folder and had inserted the data
using pgcrypto encrypt function .

here the problem comes, I was trying to decrypt the data but it was
throwing me the below error

ERROR: invalid byte sequence for encoding "UTF8": 0x95

Please find the below process which I followed

Generated the keys :
CREATE EXTENSION pgcrypto;

$ gpg --list-keys
/home/ec2-user/.gnupg/pubring.gpg
--------------------------------

pub 2048R/8GGGFF 2020-03-19
uid [ultimate] postgres
sub 2048R/GGGFF7 2020-03-19

create table users(username varchar(100),id integer,ssn bytea);

postgres=# INSERT INTO users
VALUES('randomname',7,pgp_pub_encrypt('434-88-8880',dearmor(pg_read_file('keys/public.key'))));

INSERT 0 1

postgres=# SELECT
pgp_pub_decrypt(ssn,dearmor(pg_read_file('keys/private.key'))) AS mydata
FROM users;

ERROR: invalid byte sequence for encoding "UTF8": 0x95

postgres=# show client_encoding;
client_encoding
-----------------
UTF8
(1 row)

postgres=# show server_encoding;
server_encoding
-----------------
UTF8
(1 row)

Can anyone please help me on this , I am not sure why I was getting this
error.

#3Chaitanya bodlapati
chaitanya.bodlapati4330@gmail.com
In reply to: Chaitanya bodlapati (#2)
Fwd: invalid byte sequence for encoding "UTF8": 0x95-while using PGP Encryption -PostgreSQL

Hi,

I was working on Asymmetric encryption in postgres using pgcrypto . I have
generated the keys and stored in data folder and had inserted the data
using pgcrypto encrypt function .

here the problem comes, I was trying to decrypt the data but it was
throwing me the below error

ERROR: invalid byte sequence for encoding "UTF8": 0x95

Please find the below process which I followed

Generated the keys :
CREATE EXTENSION pgcrypto;

$ gpg --list-keys
/home/ec2-user/.gnupg/pubring.gpg
--------------------------------

pub 2048R/8GGGFF 2020-03-19
uid [ultimate] postgres
sub 2048R/GGGFF7 2020-03-19

create table users(username varchar(100),id integer,ssn bytea);

postgres=# INSERT INTO users
VALUES('randomname',7,pgp_pub_encrypt('434-88-8880',dearmor(pg_read_file('keys/public.key'))));

INSERT 0 1

postgres=# SELECT
pgp_pub_decrypt(ssn,dearmor(pg_read_file('keys/private.key'))) AS mydata
FROM users;

ERROR: invalid byte sequence for encoding "UTF8": 0x95

postgres=# show client_encoding;
client_encoding
-----------------
UTF8
(1 row)

postgres=# show server_encoding;
server_encoding
-----------------
UTF8
(1 row)

Can anyone please help me on this , I am not sure why I was getting this
error.