473,386 Members | 1,598 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Corrupt Data error in Decryption in PostgreSQL using GnuPG

I am using GnuPG software for assymetric encryption in PostgreSQL.
I have done encryption using

Expand|Select|Wrap|Line Numbers
  1. ->INSERT INTO "test1"("test") 
  2.  ->   VALUES (pgp_pub_encrypt('testing', dearmor('------>BEGIN PGP PUBLIC KEY BLOCK-----
  3. ->Version: GnuPG v2.0.17 (MingW32)
  4.  
  5. ->..............
  6. ->-----END PGP PUBLIC KEY BLOCK-----'
  7.  
  8. ->)));
and got succeded

but when i am doing decryption with syntax:-

Expand|Select|Wrap|Line Numbers
  1. ->SELECT pgp_pub_decrypt(bytea ("test"),
  2. ->dearmor('-----BEGIN PGP PRIVATE KEY BLOCK-----
  3. ->Version: GnuPG v2.0.17 (MingW32)
  4. ->.............................
  5. ->-----END PGP PRIVATE KEY BLOCK-----'),'decrypt123')  --> ->this is the passphrase 
  6.  -> FROM "test1"; 

I am getting error as:-

->ERROR: Corrupt data

->********** Error **********

->ERROR: Corrupt data
->SQL state: 39000



Please guide me where i am going wrong..as i need this urgently
Oct 9 '12 #1
6 5988
Rabbit
12,516 Expert Mod 8TB
Please use code tags when posting code.

This is from the PostgreSQL manual: Decrypting bytea data with pgp_pub_decrypt is disallowed. This is to avoid outputting invalid character data.
Oct 9 '12 #2
I have even tried with pgp_pub_decrypt_bytea but am getting same erorr..please help..
Oct 9 '12 #3
Rabbit
12,516 Expert Mod 8TB
It could be that the public key and secret key you're using is out of sync. Try generating new pairs and using those. Or it could be that the password you're using for the secret key is wrong. It's hard to say because the error is so generic.
Oct 9 '12 #4
I regenerated the keys and even used the correct passphrase. I am still getting this error. Am i using the correct approach for public key encryption? Do i need to write some extra code for making decryption successful?
please help.
Oct 10 '12 #5
Rabbit
12,516 Expert Mod 8TB
Sorry, I haven't used that function much. Hopefully there's someone here with more experience with that.
Oct 10 '12 #6
Its ok and thanx for your help. I got success after making keys passwrdless. After removing passphrase column,decryption is successful.
Oct 11 '12 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: WebScott | last post by:
I am trying to run GnuPG encrypt and decrypt functions from a PHP script on a Win2k machine. I have tried several variations to no avail. Basically what I want to be able to do is something like...
0
by: Robert | last post by:
did you solve this problem? It seems to be still present here with py2.3.5. Robert -- From: Manish Jethani <manish.j@gmx.net> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US;...
0
by: btober | last post by:
I noticed this gem for allowing the saving of MS-Project 2000 data into a Postgresql database, http://techdocs.postgresql.org/source.php#fmsproject posted by John P Cavanaugh probably a...
3
by: Steve - DND | last post by:
I'm currently having some difficulties inserting Unicode text into a PostgreSQL database from a .Net app. The database is setup with UNICODE encoding, and .Net apps maintains all strings in a...
0
by: Rod Early | last post by:
I am working on a project where a WindowsCE device needs to talk to a PostgreSQL database. The CE application already exists and works with the MS SQL database -- we are converting the database to...
3
by: Secrétariat | last post by:
Hello ! I use a PostgreSQL server 7.4 on Linux Mandrake 10 with IP 192.168.0.15, a database gestix is created. An PostegreSQL user "postgres" id defined on this server, I add in the...
0
by: danishce | last post by:
Hello All: I am receiving data in hex format using serial communication MSCOMM control.The data reads ok but when it find hex(0) means EndofFile character in ASCII it exits and does not read data...
1
by: prathapshetty13 | last post by:
Please give some suggestions to handle shared memory concept in postgresql using c functions with simple example program.
0
by: akshalika | last post by:
I am new to Biztalk. In my project we need to connect oracle database and insert data into oracle table using BizTalk project. I use WCF Adapter pack(SP2). I create biztalk project then using Consume...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.