Skip to content

Commit 96e4adb

Browse files
committed
Remove oic dependency.
1 parent 72dc685 commit 96e4adb

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

tests/test_07_jwe.py

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# from __future__ import print_function
22
import hashlib
33
import os
4+
import string
45
import sys
56
import array
67

78
import pytest
89
from cryptography.hazmat.backends import default_backend
910
from cryptography.hazmat.primitives.asymmetric import ec
10-
from oic import rndstr
1111

12-
from cryptojwt.exception import MissingKey, BadSyntax, HeaderError
12+
from cryptojwt.exception import BadSyntax
13+
from cryptojwt.exception import HeaderError
14+
from cryptojwt.exception import MissingKey
1315
from cryptojwt.exception import Unsupported
1416
from cryptojwt.exception import VerificationError
15-
from cryptojwt.jwe.exception import UnsupportedBitLength, \
16-
NoSuitableEncryptionKey, WrongEncryptionAlgorithm, NoSuitableDecryptionKey
17-
17+
from cryptojwt.jwe.exception import NoSuitableDecryptionKey
18+
from cryptojwt.jwe.exception import NoSuitableEncryptionKey
19+
from cryptojwt.jwe.exception import UnsupportedBitLength
20+
from cryptojwt.jwe.exception import WrongEncryptionAlgorithm
1821
from cryptojwt.utils import b64e, as_bytes
1922

2023
from cryptojwt.jwe.aes import AES_CBCEncrypter
@@ -34,6 +37,22 @@
3437

3538
__author__ = 'rohe0002'
3639

40+
try:
41+
import random.SystemRandom as rnd
42+
except ImportError:
43+
import random as rnd
44+
45+
46+
def rndstr(size=16):
47+
"""
48+
Returns a string of random ascii characters or digits
49+
50+
:param size: The length of the string
51+
:return: string
52+
"""
53+
_basech = string.ascii_letters + string.digits
54+
return "".join([rnd.choice(_basech) for _ in range(size)])
55+
3756

3857
def intarr2bytes(arr):
3958
return array.array('B', arr).tostring()

0 commit comments

Comments
 (0)