code: def rsa_base64_sign_str(self, plain, b64=True):
          
          with open(self.key_file) as fp:
              key_ = RSA.importKey(fp.read())
              # h = SHA.new(plain if sys.version_info < (3, 0) else plain.encode('utf-8'))
              plain = helper.to_bytes(plain)
              # if hasattr(plain, 'encode'):
              #     plain = plain.encode()
              h = SHA.new(plain)
              cipher = pkcs.new(key_).sign(h)
              cip = base64.b64encode(cipher) if b64 else cipher
              return helper.to_str(cip)
docs: 对 msg rsa 签名, 然后使用 base64 encode 编码数据