{"action":"created","issue":{"url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges/issues/37","repository_url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges","labels_url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges/issues/37/labels{/name}","comments_url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges/issues/37/comments","events_url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges/issues/37/events","html_url":"https://github.com/TheLunchtimeAttack/matasano-challenges/issues/37","id":134269643,"number":37,"title":"Bytestring vs lists","user":{"login":"TheLunchtimeAttack","id":16918972,"avatar_url":"https://avatars.githubusercontent.com/u/16918972?v=3","gravatar_id":"","url":"https://api.github.com/users/TheLunchtimeAttack","html_url":"https://github.com/TheLunchtimeAttack","followers_url":"https://api.github.com/users/TheLunchtimeAttack/followers","following_url":"https://api.github.com/users/TheLunchtimeAttack/following{/other_user}","gists_url":"https://api.github.com/users/TheLunchtimeAttack/gists{/gist_id}","starred_url":"https://api.github.com/users/TheLunchtimeAttack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheLunchtimeAttack/subscriptions","organizations_url":"https://api.github.com/users/TheLunchtimeAttack/orgs","repos_url":"https://api.github.com/users/TheLunchtimeAttack/repos","events_url":"https://api.github.com/users/TheLunchtimeAttack/events{/privacy}","received_events_url":"https://api.github.com/users/TheLunchtimeAttack/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"TheLunchtimeAttack","id":16918972,"avatar_url":"https://avatars.githubusercontent.com/u/16918972?v=3","gravatar_id":"","url":"https://api.github.com/users/TheLunchtimeAttack","html_url":"https://github.com/TheLunchtimeAttack","followers_url":"https://api.github.com/users/TheLunchtimeAttack/followers","following_url":"https://api.github.com/users/TheLunchtimeAttack/following{/other_user}","gists_url":"https://api.github.com/users/TheLunchtimeAttack/gists{/gist_id}","starred_url":"https://api.github.com/users/TheLunchtimeAttack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TheLunchtimeAttack/subscriptions","organizations_url":"https://api.github.com/users/TheLunchtimeAttack/orgs","repos_url":"https://api.github.com/users/TheLunchtimeAttack/repos","events_url":"https://api.github.com/users/TheLunchtimeAttack/events{/privacy}","received_events_url":"https://api.github.com/users/TheLunchtimeAttack/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2016-02-17T12:45:47Z","updated_at":"2016-02-24T11:17:04Z","closed_at":null,"body":"Which one is better to use? \r\n\r\nDiscuss..."},"comment":{"url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges/issues/comments/188200644","html_url":"https://github.com/TheLunchtimeAttack/matasano-challenges/issues/37#issuecomment-188200644","issue_url":"https://api.github.com/repos/TheLunchtimeAttack/matasano-challenges/issues/37","id":188200644,"user":{"login":"gchers","id":2278118,"avatar_url":"https://avatars.githubusercontent.com/u/2278118?v=3","gravatar_id":"","url":"https://api.github.com/users/gchers","html_url":"https://github.com/gchers","followers_url":"https://api.github.com/users/gchers/followers","following_url":"https://api.github.com/users/gchers/following{/other_user}","gists_url":"https://api.github.com/users/gchers/gists{/gist_id}","starred_url":"https://api.github.com/users/gchers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gchers/subscriptions","organizations_url":"https://api.github.com/users/gchers/orgs","repos_url":"https://api.github.com/users/gchers/repos","events_url":"https://api.github.com/users/gchers/events{/privacy}","received_events_url":"https://api.github.com/users/gchers/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T11:17:04Z","updated_at":"2016-02-24T11:17:04Z","body":"It is quite common in Python to represent a string of bytes as a string object, in which each character represents one byte. For example, the string of bytes:\r\n```\r\n0xcc0bfa41\r\n```\r\ncan be represented as:\r\n```\r\n'\\xcc\\x0b\\xfaA'\r\n```\r\nYou can see that '\\xcc' represents the byte 0xcc, and so on.\r\nNotice that the byte 0x41 is converted to its ASCII value 'A' [1].\r\n\r\nThis convention is quite handy, and many libraries adopt it.\r\nFor example, see pycrypto [2] and scapy [3,4].\r\n\r\nThe library *binascii* [5] allows to easily move from a string of hexadecimal values to its binary form:\r\n```\r\nimport binascii\r\nhex_representation = 'cc0bfa41'\r\nbin_representation = binascii.unhexlify(hex_representation)\r\n```\r\nbin_representation takes value '\\xcc\\x0b\\xfaA'.\r\n\r\nAdvantages of using this convention: i) commonly used, ii) many libraries support it directly, iii) there are tools (binascii) to make its use painless.\r\n\r\nReferences\r\n[1] http://www.asciitable.com/.\r\n[2] http://docs.python-guide.org/en/latest/scenarios/crypto/.\r\n[3] http://www.secdev.org/projects/scapy/.\r\n[4] http://www.secdev.org/projects/scapy/doc/usage.html.\r\n[5] http://effbot.org/librarybook/binascii.htm."}}