aboutsummaryrefslogtreecommitdiffstats
path: root/docs/hazmat
diff options
context:
space:
mode:
Diffstat (limited to 'docs/hazmat')
-rw-r--r--docs/hazmat/primitives/aead.rst6
-rw-r--r--docs/hazmat/primitives/asymmetric/ec.rst4
-rw-r--r--docs/hazmat/primitives/asymmetric/rsa.rst6
-rw-r--r--docs/hazmat/primitives/cryptographic-hashes.rst2
-rw-r--r--docs/hazmat/primitives/mac/cmac.rst2
-rw-r--r--docs/hazmat/primitives/mac/hmac.rst2
-rw-r--r--docs/hazmat/primitives/padding.rst16
-rw-r--r--docs/hazmat/primitives/symmetric-encryption.rst12
8 files changed, 25 insertions, 25 deletions
diff --git a/docs/hazmat/primitives/aead.rst b/docs/hazmat/primitives/aead.rst
index 7b01f745..ee4214a1 100644
--- a/docs/hazmat/primitives/aead.rst
+++ b/docs/hazmat/primitives/aead.rst
@@ -34,7 +34,7 @@ also support providing integrity for associated data which is not encrypted.
>>> nonce = os.urandom(12)
>>> ct = chacha.encrypt(nonce, data, aad)
>>> chacha.decrypt(nonce, ct, aad)
- 'a secret message'
+ b'a secret message'
.. classmethod:: generate_key()
@@ -99,7 +99,7 @@ also support providing integrity for associated data which is not encrypted.
>>> nonce = os.urandom(12)
>>> ct = aesgcm.encrypt(nonce, data, aad)
>>> aesgcm.decrypt(nonce, ct, aad)
- 'a secret message'
+ b'a secret message'
.. classmethod:: generate_key(bit_length)
@@ -181,7 +181,7 @@ also support providing integrity for associated data which is not encrypted.
>>> nonce = os.urandom(13)
>>> ct = aesccm.encrypt(nonce, data, aad)
>>> aesccm.decrypt(nonce, ct, aad)
- 'a secret message'
+ b'a secret message'
.. classmethod:: generate_key(bit_length)
diff --git a/docs/hazmat/primitives/asymmetric/ec.rst b/docs/hazmat/primitives/asymmetric/ec.rst
index edcfdfcb..bbab2246 100644
--- a/docs/hazmat/primitives/asymmetric/ec.rst
+++ b/docs/hazmat/primitives/asymmetric/ec.rst
@@ -669,7 +669,7 @@ This sample demonstrates how to generate a private key and serialize it.
... encryption_algorithm=serialization.BestAvailableEncryption(b'testpassword')
... )
>>> serialized_private.splitlines()[0]
- '-----BEGIN ENCRYPTED PRIVATE KEY-----'
+ b'-----BEGIN ENCRYPTED PRIVATE KEY-----'
You can also serialize the key without a password, by relying on
:class:`~cryptography.hazmat.primitives.serialization.NoEncryption`.
@@ -685,7 +685,7 @@ The public key is serialized as follows:
... format=serialization.PublicFormat.SubjectPublicKeyInfo
... )
>>> serialized_public.splitlines()[0]
- '-----BEGIN PUBLIC KEY-----'
+ b'-----BEGIN PUBLIC KEY-----'
This is the part that you would normally share with the rest of the world.
diff --git a/docs/hazmat/primitives/asymmetric/rsa.rst b/docs/hazmat/primitives/asymmetric/rsa.rst
index 46cc30af..635a4626 100644
--- a/docs/hazmat/primitives/asymmetric/rsa.rst
+++ b/docs/hazmat/primitives/asymmetric/rsa.rst
@@ -100,7 +100,7 @@ to serialize the key.
... encryption_algorithm=serialization.BestAvailableEncryption(b'mypassword')
... )
>>> pem.splitlines()[0]
- '-----BEGIN ENCRYPTED PRIVATE KEY-----'
+ b'-----BEGIN ENCRYPTED PRIVATE KEY-----'
It is also possible to serialize without encryption using
:class:`~cryptography.hazmat.primitives.serialization.NoEncryption`.
@@ -113,7 +113,7 @@ It is also possible to serialize without encryption using
... encryption_algorithm=serialization.NoEncryption()
... )
>>> pem.splitlines()[0]
- '-----BEGIN RSA PRIVATE KEY-----'
+ b'-----BEGIN RSA PRIVATE KEY-----'
For public keys you can use
:meth:`~cryptography.hazmat.primitives.asymmetric.rsa.RSAPublicKey.public_bytes`
@@ -128,7 +128,7 @@ to serialize the key.
... format=serialization.PublicFormat.SubjectPublicKeyInfo
... )
>>> pem.splitlines()[0]
- '-----BEGIN PUBLIC KEY-----'
+ b'-----BEGIN PUBLIC KEY-----'
Signing
~~~~~~~
diff --git a/docs/hazmat/primitives/cryptographic-hashes.rst b/docs/hazmat/primitives/cryptographic-hashes.rst
index 7e23ce9e..021e433d 100644
--- a/docs/hazmat/primitives/cryptographic-hashes.rst
+++ b/docs/hazmat/primitives/cryptographic-hashes.rst
@@ -26,7 +26,7 @@ Message digests (Hashing)
>>> digest.update(b"abc")
>>> digest.update(b"123")
>>> digest.finalize()
- 'l\xa1=R\xcap\xc8\x83\xe0\xf0\xbb\x10\x1eBZ\x89\xe8bM\xe5\x1d\xb2\xd29%\x93\xafj\x84\x11\x80\x90'
+ b'l\xa1=R\xcap\xc8\x83\xe0\xf0\xbb\x10\x1eBZ\x89\xe8bM\xe5\x1d\xb2\xd29%\x93\xafj\x84\x11\x80\x90'
If the backend doesn't support the requested ``algorithm`` an
:class:`~cryptography.exceptions.UnsupportedAlgorithm` exception will be
diff --git a/docs/hazmat/primitives/mac/cmac.rst b/docs/hazmat/primitives/mac/cmac.rst
index b316e4c3..a5b13caf 100644
--- a/docs/hazmat/primitives/mac/cmac.rst
+++ b/docs/hazmat/primitives/mac/cmac.rst
@@ -32,7 +32,7 @@ A subset of CMAC with the AES-128 algorithm is described in :rfc:`4493`.
>>> c = cmac.CMAC(algorithms.AES(key), backend=default_backend())
>>> c.update(b"message to authenticate")
>>> c.finalize()
- 'CT\x1d\xc8\x0e\x15\xbe4e\xdb\xb6\x84\xca\xd9Xk'
+ b'CT\x1d\xc8\x0e\x15\xbe4e\xdb\xb6\x84\xca\xd9Xk'
If the backend doesn't support the requested ``algorithm`` an
:class:`~cryptography.exceptions.UnsupportedAlgorithm` exception will be
diff --git a/docs/hazmat/primitives/mac/hmac.rst b/docs/hazmat/primitives/mac/hmac.rst
index a0e2014d..c605e58c 100644
--- a/docs/hazmat/primitives/mac/hmac.rst
+++ b/docs/hazmat/primitives/mac/hmac.rst
@@ -32,7 +32,7 @@ of a message.
>>> h = hmac.HMAC(key, hashes.SHA256(), backend=default_backend())
>>> h.update(b"message to hash")
>>> h.finalize()
- '#F\xdaI\x8b"e\xc4\xf1\xbb\x9a\x8fc\xff\xf5\xdex.\xbc\xcd/+\x8a\x86\x1d\x84\'\xc3\xa6\x1d\xd8J'
+ b'#F\xdaI\x8b"e\xc4\xf1\xbb\x9a\x8fc\xff\xf5\xdex.\xbc\xcd/+\x8a\x86\x1d\x84\'\xc3\xa6\x1d\xd8J'
If the backend doesn't support the requested ``algorithm`` an
:class:`~cryptography.exceptions.UnsupportedAlgorithm` exception will be
diff --git a/docs/hazmat/primitives/padding.rst b/docs/hazmat/primitives/padding.rst
index e49fc494..245b5547 100644
--- a/docs/hazmat/primitives/padding.rst
+++ b/docs/hazmat/primitives/padding.rst
@@ -25,16 +25,16 @@ multiple of the block size.
>>> padder = padding.PKCS7(128).padder()
>>> padded_data = padder.update(b"11111111111111112222222222")
>>> padded_data
- '1111111111111111'
+ b'1111111111111111'
>>> padded_data += padder.finalize()
>>> padded_data
- '11111111111111112222222222\x06\x06\x06\x06\x06\x06'
+ b'11111111111111112222222222\x06\x06\x06\x06\x06\x06'
>>> unpadder = padding.PKCS7(128).unpadder()
>>> data = unpadder.update(padded_data)
>>> data
- '1111111111111111'
+ b'1111111111111111'
>>> data + unpadder.finalize()
- '11111111111111112222222222'
+ b'11111111111111112222222222'
:param block_size: The size of the block in :term:`bits` that the data is
being padded to.
@@ -68,16 +68,16 @@ multiple of the block size.
>>> padder = padding.ANSIX923(128).padder()
>>> padded_data = padder.update(b"11111111111111112222222222")
>>> padded_data
- '1111111111111111'
+ b'1111111111111111'
>>> padded_data += padder.finalize()
>>> padded_data
- '11111111111111112222222222\x00\x00\x00\x00\x00\x06'
+ b'11111111111111112222222222\x00\x00\x00\x00\x00\x06'
>>> unpadder = padding.ANSIX923(128).unpadder()
>>> data = unpadder.update(padded_data)
>>> data
- '1111111111111111'
+ b'1111111111111111'
>>> data + unpadder.finalize()
- '11111111111111112222222222'
+ b'11111111111111112222222222'
:param block_size: The size of the block in :term:`bits` that the data is
being padded to.
diff --git a/docs/hazmat/primitives/symmetric-encryption.rst b/docs/hazmat/primitives/symmetric-encryption.rst
index 126a9184..593b880b 100644
--- a/docs/hazmat/primitives/symmetric-encryption.rst
+++ b/docs/hazmat/primitives/symmetric-encryption.rst
@@ -42,7 +42,7 @@ it fits your needs before implementing anything using this module.**
>>> ct = encryptor.update(b"a secret message") + encryptor.finalize()
>>> decryptor = cipher.decryptor()
>>> decryptor.update(ct) + decryptor.finalize()
- 'a secret message'
+ b'a secret message'
:param algorithms: A
:class:`~cryptography.hazmat.primitives.ciphers.CipherAlgorithm`
@@ -151,7 +151,7 @@ Algorithms
>>> ct = encryptor.update(b"a secret message")
>>> decryptor = cipher.decryptor()
>>> decryptor.update(ct)
- 'a secret message'
+ b'a secret message'
.. class:: TripleDES(key)
@@ -229,7 +229,7 @@ Weak ciphers
>>> ct = encryptor.update(b"a secret message")
>>> decryptor = cipher.decryptor()
>>> decryptor.update(ct)
- 'a secret message'
+ b'a secret message'
.. class:: IDEA(key)
@@ -278,7 +278,7 @@ Modes
.. doctest::
>>> from cryptography.hazmat.primitives.ciphers.modes import CBC
- >>> iv = "a" * 16
+ >>> iv = b"a" * 16
>>> mode = CBC(iv)
@@ -471,7 +471,7 @@ Modes
.. testoutput::
- a secret message!
+ b'a secret message!'
.. class:: XTS(tweak)
@@ -594,7 +594,7 @@ Interfaces
>>> len_decrypted = decryptor.update_into(ct, buf)
>>> # get the plaintext from the buffer reading only the bytes written (len_decrypted)
>>> bytes(buf[:len_decrypted]) + decryptor.finalize()
- 'a secret message'
+ b'a secret message'
.. method:: finalize()