Skip to content

Commit 28da40c

Browse files
committed
Python note: Generating a random base64 string
1 parent ed52616 commit 28da40c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Python.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ from distutils.sysconfig import get_python_lib
170170
print(get_python_lib())
171171
----
172172

173+
=== Generating a random base64 string
174+
175+
```python
176+
import os
177+
import base64
178+
179+
180+
string_length = 32
181+
random_string = base64.urlsafe_b64encode(os.urandom(string_length))
182+
```
183+
173184
=== Generating SSH key pairs on file system
174185

175186
Requirement: Pycrypto.

0 commit comments

Comments
 (0)