Обсуждение: does encrypt function support higher than basic ascii?

Поиск
Список
Период
Сортировка

does encrypt function support higher than basic ascii?

От
"Naoko Reeves"
Дата:

Hello,

I have the following statement and accent e doesn’t seems to be decrypted correctly.

select decrypt(encrypt('aéiou','foo','aes'),'foo','aes')

Could you tell me if there is an option for encoding or this function only encrypt basic ascii?

 

Thank you very much for your time in advance.

Naoko

 

Re: does encrypt function support higher than basic ascii?

От
Richard Huxton
Дата:
Naoko Reeves wrote:
> Hello,
>
> I have the following statement and accent e doesn't seems to be
> decrypted correctly.
>
> select decrypt(encrypt('aéiou','foo','aes'),'foo','aes')
>
> Could you tell me if there is an option for encoding or this function
> only encrypt basic ascii?

They take bytea rather than text and return bytea too.

Does casting the result give you valid text?

--
  Richard Huxton
  Archonet Ltd

Re: does encrypt function support higher than basic ascii?

От
"Naoko Reeves"
Дата:
I have tried:
select decrypt(encrypt((select convert('aéiou','UTF8', 'LATIN1')),'foo','aes'),'foo','aes')
select decrypt(encrypt((select convert('aéiou','UNICODE', 'LATIN1')),'foo','aes'),'foo','aes')
select decrypt(encrypt((select convert('aéiou','LATIN1', 'LATIN1')),'foo','aes'),'foo','aes')

but none of above seems to be resolving the issue...

-----Original Message-----
From: Richard Huxton [mailto:dev@archonet.com]
Sent: Tuesday, November 17, 2009 1:14 PM
To: Naoko Reeves
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] does encrypt function support higher than basic ascii?

Naoko Reeves wrote:
> Hello,
>
> I have the following statement and accent e doesn't seems to be
> decrypted correctly.
>
> select decrypt(encrypt('aéiou','foo','aes'),'foo','aes')
>
> Could you tell me if there is an option for encoding or this function
> only encrypt basic ascii?

They take bytea rather than text and return bytea too.

Does casting the result give you valid text?

--
  Richard Huxton
  Archonet Ltd

Re: does encrypt function support higher than basic ascii?

От
"Naoko Reeves"
Дата:
Sorry, as Richard said the issue was me not converting bytea to text. The blow did it . thank you!

SELECT convert_from((select decrypt(encrypt((select convert('aéiou','LATIN1',
'LATIN1')),'foo','aes'),'foo','aes')),'UNICODE')


-----Original Message-----
From: pgsql-general-owner@postgresql.org [mailto:pgsql-general-owner@postgresql.org] On Behalf Of Naoko Reeves
Sent: Tuesday, November 17, 2009 1:38 PM
To: Richard Huxton
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] does encrypt function support higher than basic ascii?

I have tried:
select decrypt(encrypt((select convert('aéiou','UTF8', 'LATIN1')),'foo','aes'),'foo','aes')
select decrypt(encrypt((select convert('aéiou','UNICODE', 'LATIN1')),'foo','aes'),'foo','aes')
select decrypt(encrypt((select convert('aéiou','LATIN1', 'LATIN1')),'foo','aes'),'foo','aes')

but none of above seems to be resolving the issue...

-----Original Message-----
From: Richard Huxton [mailto:dev@archonet.com]
Sent: Tuesday, November 17, 2009 1:14 PM
To: Naoko Reeves
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] does encrypt function support higher than basic ascii?

Naoko Reeves wrote:
> Hello,
>
> I have the following statement and accent e doesn't seems to be
> decrypted correctly.
>
> select decrypt(encrypt('aéiou','foo','aes'),'foo','aes')
>
> Could you tell me if there is an option for encoding or this function
> only encrypt basic ascii?

They take bytea rather than text and return bytea too.

Does casting the result give you valid text?

--
  Richard Huxton
  Archonet Ltd

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Re: does encrypt function support higher than basic ascii?

От
Richard Huxton
Дата:
Naoko Reeves wrote:
> Sorry, as Richard said the issue was me not converting bytea to text. The blow did it . thank you!
>
> SELECT convert_from((select decrypt(encrypt((select convert('aéiou','LATIN1',
'LATIN1')),'foo','aes'),'foo','aes')),'UNICODE')

I'm surprised you can't just do:

SELECT convert_from(
  decrypt(
    encrypt( 'aéiou'::bytea, 'foo', 'aes' )
    , 'foo', 'aes'
  )
  , 'unicode'
)

You should be able to cast to bytea simply enough. Coming back the other
way, you do need to tell it what encoding you have through convert_from().

--
  Richard Huxton
  Archonet Ltd

Re: does encrypt function support higher than basic ascii?

От
"Naoko Reeves"
Дата:
I see that's how you cast...Yes that worked PERFECTLY. I am always learning something new from the list. Thank you VERY
much!

-----Original Message-----
From: Richard Huxton [mailto:dev@archonet.com]
Sent: Tuesday, November 17, 2009 2:07 PM
To: Naoko Reeves
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] does encrypt function support higher than basic ascii?

Naoko Reeves wrote:
> Sorry, as Richard said the issue was me not converting bytea to text. The blow did it . thank you!
>
> SELECT convert_from((select decrypt(encrypt((select convert('aéiou','LATIN1',
'LATIN1')),'foo','aes'),'foo','aes')),'UNICODE')

I'm surprised you can't just do:

SELECT convert_from(
  decrypt(
    encrypt( 'aéiou'::bytea, 'foo', 'aes' )
    , 'foo', 'aes'
  )
  , 'unicode'
)

You should be able to cast to bytea simply enough. Coming back the other
way, you do need to tell it what encoding you have through convert_from().

--
  Richard Huxton
  Archonet Ltd