Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
4ba29b47
Commit
4ba29b47
authored
Nov 22, 2017
by
Jeremy Bowman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert unicode to bytes for RSA encryption
parent
3e9e97e6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
0 deletions
+5
-0
lms/djangoapps/verify_student/ssencrypt.py
+5
-0
No files found.
lms/djangoapps/verify_student/ssencrypt.py
View file @
4ba29b47
...
...
@@ -23,6 +23,7 @@ import hmac
import
logging
import
os
from
hashlib
import
md5
,
sha256
from
six
import
text_type
from
cryptography.hazmat.backends
import
default_backend
from
cryptography.hazmat.primitives
import
serialization
...
...
@@ -105,6 +106,10 @@ def rsa_encrypt(data, rsa_pub_key_bytes):
"""
`rsa_pub_key_bytes` is a byte sequence with the public key
"""
if
isinstance
(
data
,
text_type
):
data
=
data
.
encode
(
'utf-8'
)
if
isinstance
(
rsa_pub_key_bytes
,
text_type
):
rsa_pub_key_bytes
=
rsa_pub_key_bytes
.
encode
(
'utf-8'
)
if
rsa_pub_key_bytes
.
startswith
(
b
'-----'
):
key
=
serialization
.
load_pem_public_key
(
rsa_pub_key_bytes
,
backend
=
default_backend
())
elif
rsa_pub_key_bytes
.
startswith
(
b
'ssh-rsa '
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment