1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<TITLE> [pycrypto] AES, python 2.7 vs 3
</TITLE>
<LINK REL="Index" HREF="index.html" >
<LINK REL="made" HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20AES%2C%20python%202.7%20vs%203&In-Reply-To=%3CC75A84166056C94F84D238A44AF9F6AD06ED0FB4%40AUSX10MPC103.AMER.DELL.COM%3E">
<META NAME="robots" CONTENT="index,nofollow">
<style type="text/css">
pre {
white-space: pre-wrap; /* css-2.1, curent FF, Opera, Safari */
}
</style>
<META http-equiv="Content-Type" content="text/html; charset=us-ascii">
<LINK REL="Previous" HREF="000774.html">
<LINK REL="Next" HREF="000777.html">
</HEAD>
<BODY BGCOLOR="#ffffff">
<H1>[pycrypto] AES, python 2.7 vs 3</H1>
<B>Paul_Koning at Dell.com</B>
<A HREF="mailto:pycrypto%40lists.dlitz.net?Subject=Re%3A%20%5Bpycrypto%5D%20AES%2C%20python%202.7%20vs%203&In-Reply-To=%3CC75A84166056C94F84D238A44AF9F6AD06ED0FB4%40AUSX10MPC103.AMER.DELL.COM%3E"
TITLE="[pycrypto] AES, python 2.7 vs 3">Paul_Koning at Dell.com
</A><BR>
<I>Fri Feb 7 08:26:43 PST 2014</I>
<P><UL>
<LI>Previous message: <A HREF="000774.html">[pycrypto] AES, python 2.7 vs 3
</A></li>
<LI>Next message: <A HREF="000777.html">[pycrypto] AES, python 2.7 vs 3
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#776">[ date ]</a>
<a href="thread.html#776">[ thread ]</a>
<a href="subject.html#776">[ subject ]</a>
<a href="author.html#776">[ author ]</a>
</LI>
</UL>
<HR>
<!--beginarticle-->
<PRE>
On Feb 7, 2014, at 1:29 AM, Dave Pawson <<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">dave.pawson at gmail.com</A>> wrote:
><i> On 6 February 2014 16:49, Dwayne Litzenberger <<A HREF="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">dlitz at dlitz.net</A>> wrote:
</I>>><i> On Mon, Feb 03, 2014 at 03:51:06PM +0100, Mirko Dziadzka wrote:
</I>>>><i>
</I>>>><i> Hi
</I>>>><i>
</I>>>><i> Without testing or verifying:
</I>>>><i>
</I>>>><i> You should probably use bytes in Python 3, not characters.
</I>>><i>
</I>>><i>
</I>>><i> Yeah, this is a known bug. Under Python 3, PyCrypto should raise a
</I>>><i> TypeError in most places where unicode strings are used instead of bytes,
</I>>><i> but right now it just does weird things. Sorry about that.
</I>><i>
</I>><i>
</I>><i> Recently playing about with reading / writing between Linux / Windows,
</I>><i> one symptom I came across was that the decrypted string contained b' <string>'
</I>><i> is that a part of this bug?
</I>
b’something’ is Python 3 syntax for a “bytes” literal.
It’s a good idea to spend some time reading the Python 3 documentation on text vs. bytes — “str” vs. “bytes” type. They really got this right, and it completely cures the ugly mess you get in Python 2 when dealing with strings vs. their encoding.
But it is new, and it’s different from what was done before — for good reasons.
One short summary is: “str” contains text, it’s abstract, it represents Unicode characters but does not talk about encoding. “bytes” contains sequences of bytes (octets — 8 bit integers), it’s concrete, it represents encoding of data in the outside world. You convert “str” to/from “bytes” when doing I/O. Anytime you are doing operations that need sequences of bytes, the type has to be “bytes”. Encryption is one such operation.
paul
</PRE>
<!--endarticle-->
<HR>
<P><UL>
<!--threads-->
<LI>Previous message: <A HREF="000774.html">[pycrypto] AES, python 2.7 vs 3
</A></li>
<LI>Next message: <A HREF="000777.html">[pycrypto] AES, python 2.7 vs 3
</A></li>
<LI> <B>Messages sorted by:</B>
<a href="date.html#776">[ date ]</a>
<a href="thread.html#776">[ thread ]</a>
<a href="subject.html#776">[ subject ]</a>
<a href="author.html#776">[ author ]</a>
</LI>
</UL>
<hr>
<a href="http://lists.dlitz.net/cgi-bin/mailman/listinfo/pycrypto">More information about the pycrypto
mailing list</a><br>
</body></html>
|