What is a cipher?

Asked

Viewed 368 times

1

Several times I find some questions related to ciphers here in the ORpt. However I did not find any definition of it. So,

  • What would be a cipher and what its function?
  • I saw that there are several types. They are related to encryption as a hash or as encoding, usually?
  • These can be used in any language?
  • 2

    "Cipher" is basically the name given to encryption or decryption algorithms.

  • I think Base64 isn’t even considered cryptography, it’s a kind of encoding. I’m sure about the terminology in this case.

1 answer

0


I believe that "Cipher" is a very generic term, but it refers to the algorithm used by text encryption and decryption, that is how the plain text will become an ciphertext and how it will be deciphered.


A cipher can be classified by two types:

  • Cipher style:
    • Block cipher (Block cipher) (EX. CBC)
    • Stream cipher (Stream cipher) (EX. CTR, Chacha)

Historically they can cite other types of cipher, such as the substitution cipher and so on...

  • Key style:
    • Symmetric cipher (private key encryption) (EX: DES, AES)
    • Asymmetric cipher (public key cryptography) (EX: RSA)

Perhaps there are more types of classification, after all some ciphers like GCM and CCM can also guarantee confidentiality, integrity and authenticity. While others like CBC only confidentiality, requiring you to externally use some other type of authentication, as Etm via HMAC.


What would be a cipher and what its function?

The cipher is the algorithm that will be used to generate the ciphertext and to decrypt the ciphertext so that we can read. The CBC and CTR cipher are different, both are used for AES and both generate ciphertext and decrypt text.

The cipher is how the text will be encrypted.

I saw that there are several types. They are related to encryption as a hash or as encoding, usually?

Neither. The cipher is related to encryption, the generation of ciphertext.

Encoding does not involve key, Base64 is only an "alternative representation", in the same way that can use Hexadecimal or Decimal.

You can encode an encrypted text, for example in Openpgp there is the "ascii-Armored" that converts a binary signature to ASCII, allowing better visualization and distribution, for example.

The hash doesn’t have much here, it’s not reversible and therefore doesn’t use any cipher. It is also known as "cryptographic summary", so you can find some books. It is made so that N input bytes always result in a fixed size output, in short it is used to ensure integrity. Just to complement the case, there are also Keyed-Hash, which are hashes that have keys, such as HMAC.

What is the difference between coding, encryption and hash calculation?

These can be used in any language?

Used can be used, but most likely you will end up using a library written in C. For example Openssl and Libsodium (and many others) are written in C, C is almost a rule for encryption.

However several languages implement encryption libraries, in PHP for example, it is possible to use asymmetric encryption using Openssl via openssl_public_encrypt() or using Libsodium via crypto_box(). Now, neither of the two libraries are written in PHP, you’re using something written in C.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.