mirror of
				https://github.com/postgres/postgres.git
				synced 2025-10-29 22:49:41 +03:00 
			
		
		
		
	This was from before the hex format was available in bytea. Now we can remove the extra explicit encoding/decoding calls and rely on the default output format. Discussion: https://www.postgresql.org/message-id/flat/17dcb4f7-7ac1-e2b6-d5f7-2dfba06cd9ee%40enterprisedb.com
		
			
				
	
	
		
			25 lines
		
	
	
		
			696 B
		
	
	
	
		
			SQL
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			696 B
		
	
	
	
		
			SQL
		
	
	
	
	
	
| --
 | |
| -- DES cipher
 | |
| --
 | |
| 
 | |
| -- no official test vectors atm
 | |
| 
 | |
| -- from blowfish.sql
 | |
| SELECT encrypt('\x0123456789abcdef', '\xfedcba9876543210', 'des-ecb/pad:none');
 | |
| 
 | |
| -- empty data
 | |
| select encrypt('', 'foo', 'des');
 | |
| -- 8 bytes key
 | |
| select encrypt('foo', '01234589', 'des');
 | |
| 
 | |
| -- decrypt
 | |
| select encode(decrypt(encrypt('foo', '0123456', 'des'), '0123456', 'des'), 'escape');
 | |
| 
 | |
| -- iv
 | |
| select encrypt_iv('foo', '0123456', 'abcd', 'des');
 | |
| select encode(decrypt_iv('\x50735067b073bb93', '0123456', 'abcd', 'des'), 'escape');
 | |
| 
 | |
| -- long message
 | |
| select encrypt('Lets try a longer message.', '01234567', 'des');
 | |
| select encode(decrypt(encrypt('Lets try a longer message.', '01234567', 'des'), '01234567', 'des'), 'escape');
 |