File: test_utils_crypto.py

package info (click to toggle)
streamlink 1.0.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,588 kB
  • sloc: python: 31,121; makefile: 141; sh: 93
file content (21 lines) | stat: -rw-r--r-- 742 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import base64

import unittest

from streamlink.utils.crypto import evp_bytestokey, decrypt_openssl


class TestUtil(unittest.TestCase):
    def test_evp_bytestokey(self):
        self.assertEqual((b']A@*\xbcK*v\xb9q\x9d\x91\x10\x17\xc5\x92',
                          b'(\xb4n\xd3\xc1\x11\xe8Q\x02\x90\x9b\x1c\xfbP\xea\x0f'),
                         evp_bytestokey(b"hello", b"", 16, 16))

    def test_decrpyt(self):
        # data generated with:
        #   echo "this is a test" | openssl enc -aes-256-cbc -pass pass:"streamlink" -base64
        data = base64.b64decode("U2FsdGVkX18nVyJ6Y+ksOASMSHKuRoQ9b4DKHuPbyQc=")
        self.assertEqual(
            b"this is a test\n",
            decrypt_openssl(data, b"streamlink")
        )