Postgresql Error: Corrupt ascii-armor

3.3k views Asked by At

I am using PostgreSQL 9.3.5 and trying to encrypt data using pgp_pub_encrypt() offered by pgcrypto extension. Running SELECT pgp_pub_encrypt('Vipin', dearmor('gpg_public_key')) throws an error Corrupt ascii-armor. Please help.

I am using

1

There are 1 answers

0
Jérôme Radix On BEST ANSWER

You should put the entire key into pgp_pub_encrypt parameter like this :

SELECT pgp_pub_encrypt('Vipin', dearmor('-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1

mQGiBFR8W3ERBACKsgiAj/33Nun49c811V690UENs+2Fv/19izsJZfltcaex5iEK
DaBqPEHh98ebv1eeTC5ebw8VL/bgNbg4IBFd4QugxIy3yfO0YVYGHSHRTlrs5zkq
VybfvpbQjoeRUsuDkr0vHsoq1Qdrj5ujKLoTbnNHk7K5LAdatvxf1oZQ+wCg/vty
RVOHsQc+ohID22fvv8gJnxUD/RUja2u3eZicuLuADVqNbIuJzGxtY2wLbVCbKp5L
OGT2FfMr616NHbrM3Ve1Az0jhoqGB6II0piGHWzarYXZ6M1tIwMCXnDwngUtJXmX
tN9dAah5GNGnPVFb/bkIMG1YsWbZ+2WQ4w0wk1aSKIaw01eoFTyBED7CIJC32uYr
hKQfA/9mLK4stV57E85PK/9j6zUB64dg/bdzvznrt6NFH0PLYoEFYkZfK/Z+sgCR
o0jQ0UhTc66rymFbLKVLBv6FVfDxdZvKJdur55NiYFR9WC7vJyJsTgRGBKkqe5s3
g6EP+vxRkj8hPUBwuiP/hwYB0wQKwuiTsJ33BDVkjVLofoBdSbQgVmlwaW4gTmFn
cGFsIDx2aXBpbkBlcm9zbGFicy5jbz6IaAQTEQIAKAUCVHxbcQIbAwUJEswDAAYL
CQgHAwIGFQgCCQoLBBYCAwECHgECF4AACgkQ3p94MRvpYrg+5gCgz5Iwn2xdbJ1A
bSZebBc/KEIIirYAnRxWDtGbXn3faoStbkKd7RJXvnNguQENBFR8W3EQBACbQk/O
Udoc4nSPhnEsxw/Qn7s8uH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