sha and encryption

XML, Perl, Python, and other languages can be discussed here, even if it isn't PHP (We might forgive you).

Moderator: General Moderators

Post Reply
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

sha and encryption

Post by Calimero »

Ok, I know when you encrypt something it's very ugly to read.

But what I don't know is - let's say I have one page of 10 kb I want to encrypt:

How big would it be ( because of size and bandwith usage ) when I encrypt it with
1) sha 128
2) sha 256
...

How does the size varies in relation of encryption algorithm used.

Thanks Ahead !
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Re: sha and encryption

Post by Roja »

Calimero wrote: How does the size varies in relation of encryption algorithm used.
A couple of issues with your question.

First, sha isn't encryption. Its a hashing function. You give it a variable length input (from 1 byte to billions of bytes), and it always gives a consistent length output.

The output cannot be "decrypted", and it does NOT contain all the information from the input.

Think of it like a fingerprint: While my fingerprint can identify who I am, the fingerprint is NOT me.

The second issue is that there is no sha128. There is sha1 (which is 160 bits), and sha-256 (which is 256 bits). They are commonly expressed/displayed in Hex, which results in a 40 character length for sha1, and 56 for sha-256.
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

Post by Calimero »

ok, sorry - noob in this theme.


So to ask again - if the encryption (real encryption) is used - is the encrypted material much larger then the original
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

Calimero wrote:ok, sorry - noob in this theme.
Everyone is a beginner at some point. No need to apologize. Thats what these forums are here for - for all of us to learn.

(I'm willing to bet that I'm not the most knowledgable person here about encryption)
Calimero wrote: So to ask again - if the encryption (real encryption) is used - is the encrypted material much larger then the original
It might be, or it might not.

*Most* types of encryption do indeed end up larger than the source material. However, it is usually a fairly low overhead (5-15% larger).

It can happen that it won't be, for a variety of reasons, including some encryption methods that also do compression.

So, "It depends". Which encryption method, what size input, etc etc.
User avatar
Calimero
Forum Contributor
Posts: 310
Joined: Thu Jan 22, 2004 6:54 pm
Location: Milky Way

...

Post by Calimero »

so 5 - 15 %, thanks, I needed a rough figure.


Thanks Again.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Even if it is larger - you may be able to run it through gzip compression using PHP. Depends on your actual intentions for use...
Post Reply