Enum class CharEncoding

Package: keychain.core.charencoding

Description

CharEncoding enumerates character encodings for encrypted text.

Keychain encrypt/decrypt methods operate on bytes instead of strings. When encrypting a message, users must first convert the message string into a sequence of bytes. However, a byte sequence does not tell the recipient how to piece the original string back together. Therefore when encrypting, users tell the encrypt method what character encoding was used to generate the byte sequence. This information becomes part of the ciphertext itself.

The recipient then can use this information on decrypt to recreate the original message exactly as it is intended. This is especially helpful with cross-programming-language interoperability, since every language has its own native/preferred encoding and relying on the sender and receiver to have the same understanding is faulty.

Since: v2.0

Enum Class Summary

Enum Constant Description

UTF8

the bytes represent a UTF-8 encoded string

UTF16

the bytes represent a UTF-16 encoded string

BINARY

the bytes represent binary data

ORIGINAL

an unadorned byte sequence; use this value with care

Enum Class Detail

UTF8

The bytes represent a UTF-8 encoded string. Generally if a message is decrypted and UTF8 was the encryption, the result will be a str since we can do the conversion without user intervention

UTF16

The bytes represent a UTF-16 encoded string. Generally if a message is decrypted and UTF16 was the encryption, the result will be a str since we can do the conversion without user intervention

BINARY

The bytes represent a binary data object. In this case, during decryption the bytearray will be returned as-is instead of converted to string.

ORIGINAL

The byte representation is presumed to be previously-agreed by the counterparties and is application-specific. As with BINARY, the bytearray is returned as-is.