A New Approach to Lossy Compression and Applications to Security