We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Not possible to seed .binary()
It is not possible to seed the method ``binary`` (see also issue #484)

```
>>> from faker import Faker
>>> f1 = Faker()
>>> f1.seed(4321)
>>> print(f1.binary()[0:100])
b'm\x17 ;\xca\x88\xb6\xb1\x8c/6Qmo\x02\xfa\xc3g\xf9R\xc5\xc6\x84\n\xac\xa3\x99\xb9Xs\xc3D\xa5g\xbb\xe5YU)\x95\tt\x0fsy\xe3\xaa\xfc\xaa\xb7\xb9\xfd\xac\x88\x13\xe2\xb1!\xbc\xea\x00\xd3]"\x9c;\xf2\xecx\xee\xe1\x06\xa6_\x9by\x97\xc3\xd7\xf6\x87&\x8fM\x90{\x18\xb0/\xdf\xcf$*\xde\x13\xc1\x96&\x12\xc2'
>>> f2 = Faker()
>>> f2.seed(4321)
>>> print(f2.binary()[0:100])
b"\xc1Xf\x81\xba\xe8P\xcb\xb2\xfd\x8e\x8bz7'\xe0\x7f\xef\xdej\xf5\xb8\xf1\xe4\x97v\x7f\x9aM\xfb\xee\xabT\x17\x9c\xb7\xa6\x8f\xd1\x8c\x07l0\xc5&*\xd8\xf2B\xbf\xbe\xe8\xca\xbe\xe8\xdf\xec4\xd2\xc1\xff\xecI\xc9\xdc\xae\x92~|\xa1\x0ch\x08\\G\xd7\xd8\xf0I\xc0\xcaLR\xaa\xd6{%\xfa\x14\xd9C\x9f\x1fK\x14\xc0s?O)"
```

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `faker/providers/misc/__init__.py`
Content:
```
1 # coding=utf-8
2 
3 from __future__ import unicode_literals
4 import hashlib
5 import string
6 import uuid
7 import os
8 
9 from faker.generator import random
10 from faker.providers.date_time import Provider as DatetimeProvider
11 
12 from .. import BaseProvider
13 
14 
15 class Provider(BaseProvider):
16     # Locales supported by Linux Mint from `/usr/share/i18n/SUPPORTED`
17     language_locale_codes = {
18         'aa': ('DJ', 'ER', 'ET'), 'af': ('ZA',), 'ak': ('GH',), 'am': ('ET',),
19         'an': ('ES',), 'apn': ('IN',),
20         'ar': ('AE', 'BH', 'DZ', 'EG', 'IN', 'IQ', 'JO', 'KW', 'LB', 'LY',
21                'MA', 'OM', 'QA', 'SA', 'SD', 'SS', 'SY', 'TN', 'YE'),
22         'as': ('IN',), 'ast': ('ES',), 'ayc': ('PE',), 'az': ('AZ', 'IN'),
23         'be': ('BY',), 'bem': ('ZM',), 'ber': ('DZ', 'MA'), 'bg': ('BG',),
24         'bhb': ('IN',), 'bho': ('IN',), 'bn': ('BD', 'IN'), 'bo': ('CN', 'IN'),
25         'br': ('FR',), 'brx': ('IN',), 'bs': ('BA',), 'byn': ('ER',),
26         'ca': ('AD', 'ES', 'FR', 'IT'), 'ce': ('RU',), 'ckb': ('IQ',),
27         'cmn': ('TW',), 'crh': ('UA',), 'cs': ('CZ',), 'csb': ('PL',),
28         'cv': ('RU',), 'cy': ('GB',), 'da': ('DK',),
29         'de': ('AT', 'BE', 'CH', 'DE', 'LI', 'LU'), 'doi': ('IN',),
30         'dv': ('MV',), 'dz': ('BT',), 'el': ('GR', 'CY'),
31         'en': ('AG', 'AU', 'BW', 'CA', 'DK', 'GB', 'HK', 'IE', 'IN', 'NG',
32                'NZ', 'PH', 'SG', 'US', 'ZA', 'ZM', 'ZW'),
33         'eo': ('US',),
34         'es': ('AR', 'BO', 'CL', 'CO', 'CR', 'CU', 'DO', 'EC', 'ES', 'GT',
35                'HN', 'MX', 'NI', 'PA', 'PE', 'PR', 'PY', 'SV', 'US', 'UY', 'VE'
36                ), 'et': ('EE',), 'eu': ('ES', 'FR'), 'fa': ('IR',),
37         'ff': ('SN',), 'fi': ('FI',), 'fil': ('PH',), 'fo': ('FO',),
38         'fr': ('CA', 'CH', 'FR', 'LU'), 'fur': ('IT',), 'fy': ('NL', 'DE'),
39         'ga': ('IE',), 'gd': ('GB',), 'gez': ('ER', 'ET'), 'gl': ('ES',),
40         'gu': ('IN',), 'gv': ('GB',), 'ha': ('NG',), 'hak': ('TW',),
41         'he': ('IL',), 'hi': ('IN',), 'hne': ('IN',), 'hr': ('HR',),
42         'hsb': ('DE',), 'ht': ('HT',), 'hu': ('HU',), 'hy': ('AM',),
43         'ia': ('FR',), 'id': ('ID',), 'ig': ('NG',), 'ik': ('CA',),
44         'is': ('IS',), 'it': ('CH', 'IT'), 'iu': ('CA',), 'iw': ('IL',),
45         'ja': ('JP',), 'ka': ('GE',), 'kk': ('KZ',), 'kl': ('GL',),
46         'km': ('KH',), 'kn': ('IN',), 'ko': ('KR',), 'kok': ('IN',),
47         'ks': ('IN',), 'ku': ('TR',), 'kw': ('GB',), 'ky': ('KG',),
48         'lb': ('LU',), 'lg': ('UG',), 'li': ('BE', 'NL'), 'lij': ('IT',),
49         'ln': ('CD',), 'lo': ('LA',), 'lt': ('LT',), 'lv': ('LV',),
50         'lzh': ('TW',), 'mag': ('IN',), 'mai': ('IN',), 'mg': ('MG',),
51         'mhr': ('RU',), 'mi': ('NZ',), 'mk': ('MK',), 'ml': ('IN',),
52         'mn': ('MN',), 'mni': ('IN',), 'mr': ('IN',), 'ms': ('MY',),
53         'mt': ('MT',), 'my': ('MM',), 'nan': ('TW',), 'nb': ('NO',),
54         'nds': ('DE', 'NL'), 'ne': ('NP',), 'nhn': ('MX',),
55         'niu': ('NU', 'NZ'), 'nl': ('AW', 'BE', 'NL'), 'nn': ('NO',),
56         'nr': ('ZA',), 'nso': ('ZA',), 'oc': ('FR',), 'om': ('ET', 'KE'),
57         'or': ('IN',), 'os': ('RU',), 'pa': ('IN', 'PK'),
58         'pap': ('AN', 'AW', 'CW'), 'pl': ('PL',), 'ps': ('AF',),
59         'pt': ('BR', 'PT'), 'quz': ('PE',), 'raj': ('IN',), 'ro': ('RO',),
60         'ru': ('RU', 'UA'), 'rw': ('RW',), 'sa': ('IN',), 'sat': ('IN',),
61         'sc': ('IT',), 'sd': ('IN', 'PK'), 'se': ('NO',), 'shs': ('CA',),
62         'si': ('LK',), 'sid': ('ET',), 'sk': ('SK',), 'sl': ('SI',),
63         'so': ('DJ', 'ET', 'KE', 'SO'), 'sq': ('AL', 'ML'), 'sr': ('ME', 'RS'),
64         'ss': ('ZA',), 'st': ('ZA',), 'sv': ('FI', 'SE'), 'sw': ('KE', 'TZ'),
65         'szl': ('PL',), 'ta': ('IN', 'LK'), 'tcy': ('IN',), 'te': ('IN',),
66         'tg': ('TJ',), 'th': ('TH',), 'the': ('NP',), 'ti': ('ER', 'ET'),
67         'tig': ('ER',), 'tk': ('TM',), 'tl': ('PH',), 'tn': ('ZA',),
68         'tr': ('CY', 'TR'), 'ts': ('ZA',), 'tt': ('RU',), 'ug': ('CN',),
69         'uk': ('UA',), 'unm': ('US',), 'ur': ('IN', 'PK'), 'uz': ('UZ',),
70         've': ('ZA',), 'vi': ('VN',), 'wa': ('BE',), 'wae': ('CH',),
71         'wal': ('ET',), 'wo': ('SN',), 'xh': ('ZA',), 'yi': ('US',),
72         'yo': ('NG',), 'yue': ('HK',), 'zh': ('CN', 'HK', 'SG', 'TW'),
73         'zu': ('ZA',)
74     }
75 
76     @classmethod
77     def boolean(cls, chance_of_getting_true=50):
78         return random.randint(1, 100) <= chance_of_getting_true
79 
80     @classmethod
81     def null_boolean(cls):
82         return {
83             0: None,
84             1: True,
85             -1: False
86         }[random.randint(-1, 1)]
87 
88     @classmethod
89     def binary(cls, length=(1 * 1024 * 1024)):
90         """ Returns random binary blob.
91 
92         Default blob size is 1 Mb.
93         """
94         return os.urandom(length)
95 
96     @classmethod
97     def md5(cls, raw_output=False):
98         """
99         Calculates the md5 hash of a given string
100         :example 'cfcd208495d565ef66e7dff9f98764da'
101         """
102         res = hashlib.md5(str(random.random()).encode('utf-8'))
103         if raw_output:
104             return res.digest()
105         return res.hexdigest()
106 
107     @classmethod
108     def sha1(cls, raw_output=False):
109         """
110         Calculates the sha1 hash of a given string
111         :example 'b5d86317c2a144cd04d0d7c03b2b02666fafadf2'
112         """
113         res = hashlib.sha1(str(random.random()).encode('utf-8'))
114         if raw_output:
115             return res.digest()
116         return res.hexdigest()
117 
118     @classmethod
119     def sha256(cls, raw_output=False):
120         """
121         Calculates the sha256 hash of a given string
122         :example '85086017559ccc40638fcde2fecaf295e0de7ca51b7517b6aebeaaf75b4d4654'
123         """
124         res = hashlib.sha256(str(random.random()).encode('utf-8'))
125         if raw_output:
126             return res.digest()
127         return res.hexdigest()
128 
129     @classmethod
130     def locale(cls):
131         language_code = cls.language_code()
132         return language_code + '_' + cls.random_element(
133             cls.language_locale_codes[language_code]
134         )
135 
136     @classmethod
137     def language_code(cls):
138         return cls.random_element(cls.language_locale_codes.keys())
139 
140     @classmethod
141     def uuid4(cls):
142         """
143         Generates a random UUID4 string.
144         """
145         # Based on http://stackoverflow.com/q/41186818
146         return str(uuid.UUID(int=random.getrandbits(128)))
147 
148     @classmethod
149     def password(cls, length=10, special_chars=True, digits=True, upper_case=True, lower_case=True):
150         """
151         Generates a random password.
152         @param length: Integer. Length of a password
153         @param special_chars: Boolean. Whether to use special characters !@#$%^&*()_+
154         @param digits: Boolean. Whether to use digits
155         @param upper_case: Boolean. Whether to use upper letters
156         @param lower_case: Boolean. Whether to use lower letters
157         @return: String. Random password
158         """
159         choices = ""
160         required_tokens = []
161         if special_chars:
162             required_tokens.append(random.choice("!@#$%^&*()_+"))
163             choices += "!@#$%^&*()_+"
164         if digits:
165             required_tokens.append(random.choice(string.digits))
166             choices += string.digits
167         if upper_case:
168             required_tokens.append(random.choice(string.ascii_uppercase))
169             choices += string.ascii_uppercase
170         if lower_case:
171             required_tokens.append(random.choice(string.ascii_lowercase))
172             choices += string.ascii_lowercase
173 
174         assert len(required_tokens) <= length, "Required length is shorter than required characters"
175 
176         # Generate a first version of the password
177         chars = [random.choice(choices) for x in range(length)]
178 
179         # Pick some unique locations
180         random_indexes = set()
181         while len(random_indexes) < len(required_tokens):
182             random_indexes.add(random.randint(0, len(chars) - 1))
183 
184         # Replace them with the required characters
185         for i, index in enumerate(random_indexes):
186             chars[index] = required_tokens[i]
187 
188         return ''.join(chars)
189
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/faker/providers/misc/__init__.py b/faker/providers/misc/__init__.py
--- a/faker/providers/misc/__init__.py
+++ b/faker/providers/misc/__init__.py
@@ -5,6 +5,7 @@
 import string
 import uuid
 import os
+import sys
 
 from faker.generator import random
 from faker.providers.date_time import Provider as DatetimeProvider
@@ -91,7 +92,8 @@
 
         Default blob size is 1 Mb.
         """
-        return os.urandom(length)
+        blob = [random.randrange(256) for o in range(length)]
+        return bytes(blob) if sys.version_info[0] >= 3 else bytearray(blob)
 
     @classmethod
     def md5(cls, raw_output=False):

{"golden_diff": "diff --git a/faker/providers/misc/__init__.py b/faker/providers/misc/__init__.py\n--- a/faker/providers/misc/__init__.py\n+++ b/faker/providers/misc/__init__.py\n@@ -5,6 +5,7 @@\n import string\n import uuid\n import os\n+import sys\n \n from faker.generator import random\n from faker.providers.date_time import Provider as DatetimeProvider\n@@ -91,7 +92,8 @@\n \n         Default blob size is 1 Mb.\n         \"\"\"\n-        return os.urandom(length)\n+        blob = [random.randrange(256) for o in range(length)]\n+        return bytes(blob) if sys.version_info[0] >= 3 else bytearray(blob)\n \n     @classmethod\n     def md5(cls, raw_output=False):\n", "issue": "Not possible to seed .binary()\nIt is not possible to seed the method ``binary`` (see also issue #484)\r\n\r\n```\r\n>>> from faker import Faker\r\n>>> f1 = Faker()\r\n>>> f1.seed(4321)\r\n>>> print(f1.binary()[0:100])\r\nb'm\\x17 ;\\xca\\x88\\xb6\\xb1\\x8c/6Qmo\\x02\\xfa\\xc3g\\xf9R\\xc5\\xc6\\x84\\n\\xac\\xa3\\x99\\xb9Xs\\xc3D\\xa5g\\xbb\\xe5YU)\\x95\\tt\\x0fsy\\xe3\\xaa\\xfc\\xaa\\xb7\\xb9\\xfd\\xac\\x88\\x13\\xe2\\xb1!\\xbc\\xea\\x00\\xd3]\"\\x9c;\\xf2\\xecx\\xee\\xe1\\x06\\xa6_\\x9by\\x97\\xc3\\xd7\\xf6\\x87&\\x8fM\\x90{\\x18\\xb0/\\xdf\\xcf$*\\xde\\x13\\xc1\\x96&\\x12\\xc2'\r\n>>> f2 = Faker()\r\n>>> f2.seed(4321)\r\n>>> print(f2.binary()[0:100])\r\nb\"\\xc1Xf\\x81\\xba\\xe8P\\xcb\\xb2\\xfd\\x8e\\x8bz7'\\xe0\\x7f\\xef\\xdej\\xf5\\xb8\\xf1\\xe4\\x97v\\x7f\\x9aM\\xfb\\xee\\xabT\\x17\\x9c\\xb7\\xa6\\x8f\\xd1\\x8c\\x07l0\\xc5&*\\xd8\\xf2B\\xbf\\xbe\\xe8\\xca\\xbe\\xe8\\xdf\\xec4\\xd2\\xc1\\xff\\xecI\\xc9\\xdc\\xae\\x92~|\\xa1\\x0ch\\x08\\\\G\\xd7\\xd8\\xf0I\\xc0\\xcaLR\\xaa\\xd6{%\\xfa\\x14\\xd9C\\x9f\\x1fK\\x14\\xc0s?O)\"\r\n```\n", "before_files": [{"content": "# coding=utf-8\n\nfrom __future__ import unicode_literals\nimport hashlib\nimport string\nimport uuid\nimport os\n\nfrom faker.generator import random\nfrom faker.providers.date_time import Provider as DatetimeProvider\n\nfrom .. import BaseProvider\n\n\nclass Provider(BaseProvider):\n    # Locales supported by Linux Mint from `/usr/share/i18n/SUPPORTED`\n    language_locale_codes = {\n        'aa': ('DJ', 'ER', 'ET'), 'af': ('ZA',), 'ak': ('GH',), 'am': ('ET',),\n        'an': ('ES',), 'apn': ('IN',),\n        'ar': ('AE', 'BH', 'DZ', 'EG', 'IN', 'IQ', 'JO', 'KW', 'LB', 'LY',\n               'MA', 'OM', 'QA', 'SA', 'SD', 'SS', 'SY', 'TN', 'YE'),\n        'as': ('IN',), 'ast': ('ES',), 'ayc': ('PE',), 'az': ('AZ', 'IN'),\n        'be': ('BY',), 'bem': ('ZM',), 'ber': ('DZ', 'MA'), 'bg': ('BG',),\n        'bhb': ('IN',), 'bho': ('IN',), 'bn': ('BD', 'IN'), 'bo': ('CN', 'IN'),\n        'br': ('FR',), 'brx': ('IN',), 'bs': ('BA',), 'byn': ('ER',),\n        'ca': ('AD', 'ES', 'FR', 'IT'), 'ce': ('RU',), 'ckb': ('IQ',),\n        'cmn': ('TW',), 'crh': ('UA',), 'cs': ('CZ',), 'csb': ('PL',),\n        'cv': ('RU',), 'cy': ('GB',), 'da': ('DK',),\n        'de': ('AT', 'BE', 'CH', 'DE', 'LI', 'LU'), 'doi': ('IN',),\n        'dv': ('MV',), 'dz': ('BT',), 'el': ('GR', 'CY'),\n        'en': ('AG', 'AU', 'BW', 'CA', 'DK', 'GB', 'HK', 'IE', 'IN', 'NG',\n               'NZ', 'PH', 'SG', 'US', 'ZA', 'ZM', 'ZW'),\n        'eo': ('US',),\n        'es': ('AR', 'BO', 'CL', 'CO', 'CR', 'CU', 'DO', 'EC', 'ES', 'GT',\n               'HN', 'MX', 'NI', 'PA', 'PE', 'PR', 'PY', 'SV', 'US', 'UY', 'VE'\n               ), 'et': ('EE',), 'eu': ('ES', 'FR'), 'fa': ('IR',),\n        'ff': ('SN',), 'fi': ('FI',), 'fil': ('PH',), 'fo': ('FO',),\n        'fr': ('CA', 'CH', 'FR', 'LU'), 'fur': ('IT',), 'fy': ('NL', 'DE'),\n        'ga': ('IE',), 'gd': ('GB',), 'gez': ('ER', 'ET'), 'gl': ('ES',),\n        'gu': ('IN',), 'gv': ('GB',), 'ha': ('NG',), 'hak': ('TW',),\n        'he': ('IL',), 'hi': ('IN',), 'hne': ('IN',), 'hr': ('HR',),\n        'hsb': ('DE',), 'ht': ('HT',), 'hu': ('HU',), 'hy': ('AM',),\n        'ia': ('FR',), 'id': ('ID',), 'ig': ('NG',), 'ik': ('CA',),\n        'is': ('IS',), 'it': ('CH', 'IT'), 'iu': ('CA',), 'iw': ('IL',),\n        'ja': ('JP',), 'ka': ('GE',), 'kk': ('KZ',), 'kl': ('GL',),\n        'km': ('KH',), 'kn': ('IN',), 'ko': ('KR',), 'kok': ('IN',),\n        'ks': ('IN',), 'ku': ('TR',), 'kw': ('GB',), 'ky': ('KG',),\n        'lb': ('LU',), 'lg': ('UG',), 'li': ('BE', 'NL'), 'lij': ('IT',),\n        'ln': ('CD',), 'lo': ('LA',), 'lt': ('LT',), 'lv': ('LV',),\n        'lzh': ('TW',), 'mag': ('IN',), 'mai': ('IN',), 'mg': ('MG',),\n        'mhr': ('RU',), 'mi': ('NZ',), 'mk': ('MK',), 'ml': ('IN',),\n        'mn': ('MN',), 'mni': ('IN',), 'mr': ('IN',), 'ms': ('MY',),\n        'mt': ('MT',), 'my': ('MM',), 'nan': ('TW',), 'nb': ('NO',),\n        'nds': ('DE', 'NL'), 'ne': ('NP',), 'nhn': ('MX',),\n        'niu': ('NU', 'NZ'), 'nl': ('AW', 'BE', 'NL'), 'nn': ('NO',),\n        'nr': ('ZA',), 'nso': ('ZA',), 'oc': ('FR',), 'om': ('ET', 'KE'),\n        'or': ('IN',), 'os': ('RU',), 'pa': ('IN', 'PK'),\n        'pap': ('AN', 'AW', 'CW'), 'pl': ('PL',), 'ps': ('AF',),\n        'pt': ('BR', 'PT'), 'quz': ('PE',), 'raj': ('IN',), 'ro': ('RO',),\n        'ru': ('RU', 'UA'), 'rw': ('RW',), 'sa': ('IN',), 'sat': ('IN',),\n        'sc': ('IT',), 'sd': ('IN', 'PK'), 'se': ('NO',), 'shs': ('CA',),\n        'si': ('LK',), 'sid': ('ET',), 'sk': ('SK',), 'sl': ('SI',),\n        'so': ('DJ', 'ET', 'KE', 'SO'), 'sq': ('AL', 'ML'), 'sr': ('ME', 'RS'),\n        'ss': ('ZA',), 'st': ('ZA',), 'sv': ('FI', 'SE'), 'sw': ('KE', 'TZ'),\n        'szl': ('PL',), 'ta': ('IN', 'LK'), 'tcy': ('IN',), 'te': ('IN',),\n        'tg': ('TJ',), 'th': ('TH',), 'the': ('NP',), 'ti': ('ER', 'ET'),\n        'tig': ('ER',), 'tk': ('TM',), 'tl': ('PH',), 'tn': ('ZA',),\n        'tr': ('CY', 'TR'), 'ts': ('ZA',), 'tt': ('RU',), 'ug': ('CN',),\n        'uk': ('UA',), 'unm': ('US',), 'ur': ('IN', 'PK'), 'uz': ('UZ',),\n        've': ('ZA',), 'vi': ('VN',), 'wa': ('BE',), 'wae': ('CH',),\n        'wal': ('ET',), 'wo': ('SN',), 'xh': ('ZA',), 'yi': ('US',),\n        'yo': ('NG',), 'yue': ('HK',), 'zh': ('CN', 'HK', 'SG', 'TW'),\n        'zu': ('ZA',)\n    }\n\n    @classmethod\n    def boolean(cls, chance_of_getting_true=50):\n        return random.randint(1, 100) <= chance_of_getting_true\n\n    @classmethod\n    def null_boolean(cls):\n        return {\n            0: None,\n            1: True,\n            -1: False\n        }[random.randint(-1, 1)]\n\n    @classmethod\n    def binary(cls, length=(1 * 1024 * 1024)):\n        \"\"\" Returns random binary blob.\n\n        Default blob size is 1 Mb.\n        \"\"\"\n        return os.urandom(length)\n\n    @classmethod\n    def md5(cls, raw_output=False):\n        \"\"\"\n        Calculates the md5 hash of a given string\n        :example 'cfcd208495d565ef66e7dff9f98764da'\n        \"\"\"\n        res = hashlib.md5(str(random.random()).encode('utf-8'))\n        if raw_output:\n            return res.digest()\n        return res.hexdigest()\n\n    @classmethod\n    def sha1(cls, raw_output=False):\n        \"\"\"\n        Calculates the sha1 hash of a given string\n        :example 'b5d86317c2a144cd04d0d7c03b2b02666fafadf2'\n        \"\"\"\n        res = hashlib.sha1(str(random.random()).encode('utf-8'))\n        if raw_output:\n            return res.digest()\n        return res.hexdigest()\n\n    @classmethod\n    def sha256(cls, raw_output=False):\n        \"\"\"\n        Calculates the sha256 hash of a given string\n        :example '85086017559ccc40638fcde2fecaf295e0de7ca51b7517b6aebeaaf75b4d4654'\n        \"\"\"\n        res = hashlib.sha256(str(random.random()).encode('utf-8'))\n        if raw_output:\n            return res.digest()\n        return res.hexdigest()\n\n    @classmethod\n    def locale(cls):\n        language_code = cls.language_code()\n        return language_code + '_' + cls.random_element(\n            cls.language_locale_codes[language_code]\n        )\n\n    @classmethod\n    def language_code(cls):\n        return cls.random_element(cls.language_locale_codes.keys())\n\n    @classmethod\n    def uuid4(cls):\n        \"\"\"\n        Generates a random UUID4 string.\n        \"\"\"\n        # Based on http://stackoverflow.com/q/41186818\n        return str(uuid.UUID(int=random.getrandbits(128)))\n\n    @classmethod\n    def password(cls, length=10, special_chars=True, digits=True, upper_case=True, lower_case=True):\n        \"\"\"\n        Generates a random password.\n        @param length: Integer. Length of a password\n        @param special_chars: Boolean. Whether to use special characters !@#$%^&*()_+\n        @param digits: Boolean. Whether to use digits\n        @param upper_case: Boolean. Whether to use upper letters\n        @param lower_case: Boolean. Whether to use lower letters\n        @return: String. Random password\n        \"\"\"\n        choices = \"\"\n        required_tokens = []\n        if special_chars:\n            required_tokens.append(random.choice(\"!@#$%^&*()_+\"))\n            choices += \"!@#$%^&*()_+\"\n        if digits:\n            required_tokens.append(random.choice(string.digits))\n            choices += string.digits\n        if upper_case:\n            required_tokens.append(random.choice(string.ascii_uppercase))\n            choices += string.ascii_uppercase\n        if lower_case:\n            required_tokens.append(random.choice(string.ascii_lowercase))\n            choices += string.ascii_lowercase\n\n        assert len(required_tokens) <= length, \"Required length is shorter than required characters\"\n\n        # Generate a first version of the password\n        chars = [random.choice(choices) for x in range(length)]\n\n        # Pick some unique locations\n        random_indexes = set()\n        while len(random_indexes) < len(required_tokens):\n            random_indexes.add(random.randint(0, len(chars) - 1))\n\n        # Replace them with the required characters\n        for i, index in enumerate(random_indexes):\n            chars[index] = required_tokens[i]\n\n        return ''.join(chars)\n", "path": "faker/providers/misc/__init__.py"}], "after_files": [{"content": "# coding=utf-8\n\nfrom __future__ import unicode_literals\nimport hashlib\nimport string\nimport uuid\nimport os\nimport sys\n\nfrom faker.generator import random\nfrom faker.providers.date_time import Provider as DatetimeProvider\n\nfrom .. import BaseProvider\n\n\nclass Provider(BaseProvider):\n    # Locales supported by Linux Mint from `/usr/share/i18n/SUPPORTED`\n    language_locale_codes = {\n        'aa': ('DJ', 'ER', 'ET'), 'af': ('ZA',), 'ak': ('GH',), 'am': ('ET',),\n        'an': ('ES',), 'apn': ('IN',),\n        'ar': ('AE', 'BH', 'DZ', 'EG', 'IN', 'IQ', 'JO', 'KW', 'LB', 'LY',\n               'MA', 'OM', 'QA', 'SA', 'SD', 'SS', 'SY', 'TN', 'YE'),\n        'as': ('IN',), 'ast': ('ES',), 'ayc': ('PE',), 'az': ('AZ', 'IN'),\n        'be': ('BY',), 'bem': ('ZM',), 'ber': ('DZ', 'MA'), 'bg': ('BG',),\n        'bhb': ('IN',), 'bho': ('IN',), 'bn': ('BD', 'IN'), 'bo': ('CN', 'IN'),\n        'br': ('FR',), 'brx': ('IN',), 'bs': ('BA',), 'byn': ('ER',),\n        'ca': ('AD', 'ES', 'FR', 'IT'), 'ce': ('RU',), 'ckb': ('IQ',),\n        'cmn': ('TW',), 'crh': ('UA',), 'cs': ('CZ',), 'csb': ('PL',),\n        'cv': ('RU',), 'cy': ('GB',), 'da': ('DK',),\n        'de': ('AT', 'BE', 'CH', 'DE', 'LI', 'LU'), 'doi': ('IN',),\n        'dv': ('MV',), 'dz': ('BT',), 'el': ('GR', 'CY'),\n        'en': ('AG', 'AU', 'BW', 'CA', 'DK', 'GB', 'HK', 'IE', 'IN', 'NG',\n               'NZ', 'PH', 'SG', 'US', 'ZA', 'ZM', 'ZW'),\n        'eo': ('US',),\n        'es': ('AR', 'BO', 'CL', 'CO', 'CR', 'CU', 'DO', 'EC', 'ES', 'GT',\n               'HN', 'MX', 'NI', 'PA', 'PE', 'PR', 'PY', 'SV', 'US', 'UY', 'VE'\n               ), 'et': ('EE',), 'eu': ('ES', 'FR'), 'fa': ('IR',),\n        'ff': ('SN',), 'fi': ('FI',), 'fil': ('PH',), 'fo': ('FO',),\n        'fr': ('CA', 'CH', 'FR', 'LU'), 'fur': ('IT',), 'fy': ('NL', 'DE'),\n        'ga': ('IE',), 'gd': ('GB',), 'gez': ('ER', 'ET'), 'gl': ('ES',),\n        'gu': ('IN',), 'gv': ('GB',), 'ha': ('NG',), 'hak': ('TW',),\n        'he': ('IL',), 'hi': ('IN',), 'hne': ('IN',), 'hr': ('HR',),\n        'hsb': ('DE',), 'ht': ('HT',), 'hu': ('HU',), 'hy': ('AM',),\n        'ia': ('FR',), 'id': ('ID',), 'ig': ('NG',), 'ik': ('CA',),\n        'is': ('IS',), 'it': ('CH', 'IT'), 'iu': ('CA',), 'iw': ('IL',),\n        'ja': ('JP',), 'ka': ('GE',), 'kk': ('KZ',), 'kl': ('GL',),\n        'km': ('KH',), 'kn': ('IN',), 'ko': ('KR',), 'kok': ('IN',),\n        'ks': ('IN',), 'ku': ('TR',), 'kw': ('GB',), 'ky': ('KG',),\n        'lb': ('LU',), 'lg': ('UG',), 'li': ('BE', 'NL'), 'lij': ('IT',),\n        'ln': ('CD',), 'lo': ('LA',), 'lt': ('LT',), 'lv': ('LV',),\n        'lzh': ('TW',), 'mag': ('IN',), 'mai': ('IN',), 'mg': ('MG',),\n        'mhr': ('RU',), 'mi': ('NZ',), 'mk': ('MK',), 'ml': ('IN',),\n        'mn': ('MN',), 'mni': ('IN',), 'mr': ('IN',), 'ms': ('MY',),\n        'mt': ('MT',), 'my': ('MM',), 'nan': ('TW',), 'nb': ('NO',),\n        'nds': ('DE', 'NL'), 'ne': ('NP',), 'nhn': ('MX',),\n        'niu': ('NU', 'NZ'), 'nl': ('AW', 'BE', 'NL'), 'nn': ('NO',),\n        'nr': ('ZA',), 'nso': ('ZA',), 'oc': ('FR',), 'om': ('ET', 'KE'),\n        'or': ('IN',), 'os': ('RU',), 'pa': ('IN', 'PK'),\n        'pap': ('AN', 'AW', 'CW'), 'pl': ('PL',), 'ps': ('AF',),\n        'pt': ('BR', 'PT'), 'quz': ('PE',), 'raj': ('IN',), 'ro': ('RO',),\n        'ru': ('RU', 'UA'), 'rw': ('RW',), 'sa': ('IN',), 'sat': ('IN',),\n        'sc': ('IT',), 'sd': ('IN', 'PK'), 'se': ('NO',), 'shs': ('CA',),\n        'si': ('LK',), 'sid': ('ET',), 'sk': ('SK',), 'sl': ('SI',),\n        'so': ('DJ', 'ET', 'KE', 'SO'), 'sq': ('AL', 'ML'), 'sr': ('ME', 'RS'),\n        'ss': ('ZA',), 'st': ('ZA',), 'sv': ('FI', 'SE'), 'sw': ('KE', 'TZ'),\n        'szl': ('PL',), 'ta': ('IN', 'LK'), 'tcy': ('IN',), 'te': ('IN',),\n        'tg': ('TJ',), 'th': ('TH',), 'the': ('NP',), 'ti': ('ER', 'ET'),\n        'tig': ('ER',), 'tk': ('TM',), 'tl': ('PH',), 'tn': ('ZA',),\n        'tr': ('CY', 'TR'), 'ts': ('ZA',), 'tt': ('RU',), 'ug': ('CN',),\n        'uk': ('UA',), 'unm': ('US',), 'ur': ('IN', 'PK'), 'uz': ('UZ',),\n        've': ('ZA',), 'vi': ('VN',), 'wa': ('BE',), 'wae': ('CH',),\n        'wal': ('ET',), 'wo': ('SN',), 'xh': ('ZA',), 'yi': ('US',),\n        'yo': ('NG',), 'yue': ('HK',), 'zh': ('CN', 'HK', 'SG', 'TW'),\n        'zu': ('ZA',)\n    }\n\n    @classmethod\n    def boolean(cls, chance_of_getting_true=50):\n        return random.randint(1, 100) <= chance_of_getting_true\n\n    @classmethod\n    def null_boolean(cls):\n        return {\n            0: None,\n            1: True,\n            -1: False\n        }[random.randint(-1, 1)]\n\n    @classmethod\n    def binary(cls, length=(1 * 1024 * 1024)):\n        \"\"\" Returns random binary blob.\n\n        Default blob size is 1 Mb.\n        \"\"\"\n        blob = [random.randrange(256) for o in range(length)]\n        return bytes(blob) if sys.version_info[0] >= 3 else bytearray(blob)\n\n    @classmethod\n    def md5(cls, raw_output=False):\n        \"\"\"\n        Calculates the md5 hash of a given string\n        :example 'cfcd208495d565ef66e7dff9f98764da'\n        \"\"\"\n        res = hashlib.md5(str(random.random()).encode('utf-8'))\n        if raw_output:\n            return res.digest()\n        return res.hexdigest()\n\n    @classmethod\n    def sha1(cls, raw_output=False):\n        \"\"\"\n        Calculates the sha1 hash of a given string\n        :example 'b5d86317c2a144cd04d0d7c03b2b02666fafadf2'\n        \"\"\"\n        res = hashlib.sha1(str(random.random()).encode('utf-8'))\n        if raw_output:\n            return res.digest()\n        return res.hexdigest()\n\n    @classmethod\n    def sha256(cls, raw_output=False):\n        \"\"\"\n        Calculates the sha256 hash of a given string\n        :example '85086017559ccc40638fcde2fecaf295e0de7ca51b7517b6aebeaaf75b4d4654'\n        \"\"\"\n        res = hashlib.sha256(str(random.random()).encode('utf-8'))\n        if raw_output:\n            return res.digest()\n        return res.hexdigest()\n\n    @classmethod\n    def locale(cls):\n        language_code = cls.language_code()\n        return language_code + '_' + cls.random_element(\n            cls.language_locale_codes[language_code]\n        )\n\n    @classmethod\n    def language_code(cls):\n        return cls.random_element(cls.language_locale_codes.keys())\n\n    @classmethod\n    def uuid4(cls):\n        \"\"\"\n        Generates a random UUID4 string.\n        \"\"\"\n        # Based on http://stackoverflow.com/q/41186818\n        return str(uuid.UUID(int=random.getrandbits(128)))\n\n    @classmethod\n    def password(cls, length=10, special_chars=True, digits=True, upper_case=True, lower_case=True):\n        \"\"\"\n        Generates a random password.\n        @param length: Integer. Length of a password\n        @param special_chars: Boolean. Whether to use special characters !@#$%^&*()_+\n        @param digits: Boolean. Whether to use digits\n        @param upper_case: Boolean. Whether to use upper letters\n        @param lower_case: Boolean. Whether to use lower letters\n        @return: String. Random password\n        \"\"\"\n        choices = \"\"\n        required_tokens = []\n        if special_chars:\n            required_tokens.append(random.choice(\"!@#$%^&*()_+\"))\n            choices += \"!@#$%^&*()_+\"\n        if digits:\n            required_tokens.append(random.choice(string.digits))\n            choices += string.digits\n        if upper_case:\n            required_tokens.append(random.choice(string.ascii_uppercase))\n            choices += string.ascii_uppercase\n        if lower_case:\n            required_tokens.append(random.choice(string.ascii_lowercase))\n            choices += string.ascii_lowercase\n\n        assert len(required_tokens) <= length, \"Required length is shorter than required characters\"\n\n        # Generate a first version of the password\n        chars = [random.choice(choices) for x in range(length)]\n\n        # Pick some unique locations\n        random_indexes = set()\n        while len(random_indexes) < len(required_tokens):\n            random_indexes.add(random.randint(0, len(chars) - 1))\n\n        # Replace them with the required characters\n        for i, index in enumerate(random_indexes):\n            chars[index] = required_tokens[i]\n\n        return ''.join(chars)\n", "path": "faker/providers/misc/__init__.py"}]}