Is the output of hex digest constant? - hex

If I call hex digest on a SHA256 hash, any reasonable implementation should output the same length right? Is it just 512 bits?

Related

Length of AES encrypted data

I have a data that needs to be stored in a database as encrypted, the maximum length of the data before encryption is 50 chars (English or Arabic), I need to encrypt the data using AES-128 bit, and store the output in the database (base64string).
How to know the length of the data after encryption?
Try it with your specified algorithm, block size, IV size, and see what size output you get :-)
First it depends on the encoding of the input text. Is it UTF8? UTF16?
Lets assume UTF8 so 1 Byte per character means 50 Bytes of input data to your encryption algorithm. (100 Bytes if UTF16)
Then you will pad to the Block Size for the algorithm. AES, regardless of key size is a block of 16 Bytes. So we will be padded out to 64 Bytes (Or 112 for UTF 16)
Then we need to store the IV and header information. So that is (usually, with default settings/IV sizes) another 16Bytes so we are at 80 Bytes (Or 128 for UTF16)
Finally we are encoding to Base64. I assume you want string length, since otherwise it is wasteful to make it into a string. So Base 64 bloats the string using the following formula: Ceil(bytes/3) * 4. So for us that is Ceil(80/3) = 27 * 4 = 108 characters (Or 172 for UTF 16)
Again this is all highly dependent on your choices of how you encrypt, what the text is encoded as, etc.
I would try it with your scenario before relying on these numbers for anything useful.

What is the meaning of 128 bit key in AES

I am new to encryption methods and i want to know what is the meaning of 128 bit key. Does it mean the key has 128 characters or when we convert key to the binary, and then that binary has 128 digits or cipher that created using key and plain text has 128 characters ?
The key is 128 (binary) bits. That's all it means.
AES supports key sizes of 128, 192, or 256 bits.
AES has a fixed block size of 128 bits, which means it en/decrypts data in chunks of 16 bytes at a time. The plaintext/cipher text can be any length of course (and is padded out to a multiple of 16 bytes).
Good crypto implementations will use a Key Derivation Function which takes a password (or keyfile, etc) of any length, and generates a key suitable for the encryption algorithm in question.

Special characters contained in AES encryption output

I tried to find the list of possible characters that are contained in the encrypted output after AES 256 bit encryption. But, it seems like they are not on the internet? Mind to help? thanks.
The output of an AES cipher is not character data, it is simply bytes. The output should be indistinguishable from random data.
You can represent the output as a string by encoding it as Base64 or Hex if you like.

Can anyone suggest the pattern of Initialization Vector for AES 128

Can anyone suggest the pattern of Initialization vector for AES 128.
Can we include characters in IV or we have to include only numbers for it?
The IV depends on the cipher mode. But for AES with CTR, CBC, and some other modes, use 16 bytes chosen by a cryptographic random number generator.

Sign with RSA-1024 an SHA-256 digest: what is the size?

I was wondering:
1) if I compute the digest of some datas with SHA-512 => resulting in a hash of 64 bytes
2) and then I sign this hash with RSA-1024 => so a block of 128 bytes, which is bigger than the 64 bytes of the digest
=> does it mean in the end my signed hash will be exactly 128 bytes?
Thanks a lot for any info.
With RSA, as specified by PKCS#1, the data to be signed is first hashed with a hash function, then the result is padded (a more or less complex operation which transforms the hash result into a modular integer), and then the mathematical operation of RSA is applied on that number. The result is a n-bit integer, where n is the length in bits of the "modulus", usually called "the RSA key size". Basically, for RSA-1024, n is 1024. A 1024-bit integer is encoded as 128 bytes, exactly, as per the encoding method described in PKCS#1 (PKCS#1 is very readable and not too long).
Whether a n-bit RSA key can be used to sign data with a hash function which produces outputs of length m depends on the details of the padding. As the name suggests, padding involves adding some extra data around the hash output, hence n must be greater than m, leaving some room for the extra data. A 1024-bit key can be used with SHA-512 (which produces 512-bit strings). You could not use a 640-bit key with SHA-512 (and you would not, anyway, since 640-bit RSA keys can be broken -- albeit not trivially).

Resources