Internal: returns the decrypted message in this token

 Raises InvalidToken if it cannot be decrypted or is invalid

 Returns a string containing the original message in plain text
192381
def message
      if valid?
        begin
          Encryption.decrypt(key: @secret.encryption_key,
                             ciphertext: encrypted_message,
                             iv: iv)
        rescue OpenSSL::Cipher::CipherError
          raise InvalidToken, "bad decrypt"
        end
      else
        raise InvalidToken, error_messages
      end
    end
1308433
def decrypted_message_from_bytes(bytestring, session_keys=None):
    
    return decrypted_message_from_message(
        email.message_from_bytes(bytestring, policy=email.policy.SMTP),
        session_keys)
877849
def get_token(self):
        
        if self.token == None:
            self.token = self.authenticate(self.username, self.password)
        try:
            return str(self.token,'utf-8')
        except TypeError:
            return self.token
1047633
function getFormToken() {
		/*jshint validthis:true */
		if (this._csrfFormToken)
			return this._csrfFormToken;
		checkSecure(this.req);

		var cookieToken = getCookieToken(this) || createCookie(this);
		var salt = base64Random(saltSize);

		var hasher = crypto.createHmac(options.algorithm, formKey);
		hasher.update(cookieToken);
		hasher.update("|");
		hasher.update(salt);

		this._csrfFormToken = salt + "|" + hasher.digest('base64');
		return this._csrfFormToken;
	}
747336
def message(self):
        """"""
        if self.type == 'cleartext':
            return self.bytes_to_text(self._message)

        if self.type == 'literal':
            return self._message.contents

        if self.type == 'encrypted':
            return self._message
1309570
def decrypt(encoded, key: nil)

      raise ArgumentError.new('The encoded argument is required.') if encoded.blank?
      raise ArgumentError.new('The key argument is required.')     if key.blank?

      cipher = OpenSSL::Cipher::AES.new(256, 'CBC')
      cipher.decrypt
      cipher.padding = aes_256_padding
      cipher.key     = key

      cipher.update(encoded)+cipher.final

    end
1162538
def hex_decrypt(encoded, key: nil)
      Unidom::Common::Numeration.hex decrypt(Unidom::Common::Numeration.rev_hex(encoded), key: key)
    end
1268032
def token(self):
        
        if self._token is None or \
           datetime.datetime.now() >= self._token_expires_on:
            result = self._getTokenArcMap()
            if 'error' in result:
                self._valid = False
                self._message = result
            else:
                self._valid = True
                self._message = "Token Generated"
        return self._token
1265995
def decrypt password = nil, ciphertext = nil
      return @raw_content if @deferred_encryption && @raw_content

      # Given a private key and a nil password OpenSSL::PKey::RSA.new() will
      # *prompt* for a password, we default to an empty string to avoid that.
      ciphertext ||= @instance[@name]
      unless @deferred_encryption
        return nil if ciphertext.nil?
        return "" if ciphertext.empty?
      end

      return "*encrypted*" if password.nil?
      unless @private_key
        raise StrongboxError.new("#{@instance.class} model does not have private key_file")
      end

      if ciphertext
        ciphertext = Base64.decode64(ciphertext) if @base64
        private_key = get_rsa_key(@private_key,password)
        if @symmetric == :always
          random_key = @instance[@symmetric_key]
          random_iv = @instance[@symmetric_iv]
          if @base64
            random_key = Base64.decode64(random_key)
            random_iv = Base64.decode64(random_iv)
          end
          cipher = Cipher.new(@symmetric_cipher)
          cipher.decrypt
          cipher.key = private_key.private_decrypt(random_key,@padding)
          cipher.iv = private_key.private_decrypt(random_iv,@padding)
          plaintext = cipher.update(ciphertext)
          plaintext << cipher.final
        else
          plaintext = private_key.private_decrypt(ciphertext,@padding)
        end
      else
        nil
      end
    end
112449
def unwrap(self, message, signature):
        
        plain_text = _Ntlm1Session.decrypt(self, message)
        _Ntlm1Session.verify(self, plain_text, signature)
        return plain_text
210329
def unpack(self, token):
        
        if not token:
            raise KeyError

        _jwe_header = _jws_header = None

        # Check if it's an encrypted JWT
        darg = {}
        if self.allowed_enc_encs:
            darg['enc'] = self.allowed_enc_encs
        if self.allowed_enc_algs:
            darg['alg'] = self.allowed_enc_algs
        try:
            _decryptor = jwe_factory(token, **darg)
        except (KeyError, HeaderError):
            _decryptor = None

        if _decryptor:
            # Yes, try to decode
            _info = self._decrypt(_decryptor, token)
            _jwe_header = _decryptor.jwt.headers
            # Try to find out if the information encrypted was a signed JWT
            try:
                _content_type = _decryptor.jwt.headers['cty']
            except KeyError:
                _content_type = ''
        else:
            _content_type = 'jwt'
            _info = token

        # If I have reason to believe the information I have is a signed JWT
        if _content_type.lower() == 'jwt':
            # Check that is a signed JWT
            if self.allowed_sign_algs:
                _verifier = jws_factory(_info, alg=self.allowed_sign_algs)
            else:
                _verifier = jws_factory(_info)

            if _verifier:
                _info = self._verify(_verifier, _info)
            else:
                raise Exception()
            _jws_header = _verifier.jwt.headers
        else:
            # So, not a signed JWT
            try:
                # A JSON document ?
                _info = json.loads(_info)
            except JSONDecodeError:  # Oh, no ! Not JSON
                return _info
            except TypeError:
                try:
                    _info = as_unicode(_info)
                    _info = json.loads(_info)
                except JSONDecodeError:  # Oh, no ! Not JSON
                    return _info

        # If I know what message class the info should be mapped into
        if self.msg_cls:
            _msg_cls = self.msg_cls
        else:
            try:
                # try to find a issuer specific message class
                _msg_cls = self.iss2msg_cls[_info['iss']]
            except KeyError:
                _msg_cls = None

        if _msg_cls:
            vp_args = {'skew': self.skew}
            if self.iss:
                vp_args['aud'] = self.iss
            _info = self.verify_profile(_msg_cls, _info, **vp_args)
            _info.jwe_header = _jwe_header
            _info.jws_header = _jws_header
            return _info
        else:
            return _info
809326
def _message_from_token(self, token: Text, payload: Any) \
            -> Optional[BaseMessage]:
        

        try:
            tk = jwt.decode(token, settings.WEBVIEW_SECRET_KEY)
        except jwt.InvalidTokenError:
            return

        try:
            user_id = tk['fb_psid']
            assert isinstance(user_id, Text)
            page_id = tk['fb_pid']
            assert isinstance(page_id, Text)
        except (KeyError, AssertionError):
            return

        if self.settings()['page_id'] == page_id:
            return self._make_fake_message(user_id, page_id, payload)
1073475
def decrypt(message):
    '''
    '''
    try:
        ret = kms.decrypt(
            CiphertextBlob=base64.decodestring(message))
        decrypted_data = ret.get('Plaintext')
    except Exception as e:
        # returns http 500 back to user and log error details in Cloudwatch Logs
        raise Exception("Unable to decrypt data: ", e)

    return decrypted_data
957444
def decrypt_string(self, token_str, expiration_in_seconds=None):
        """"""

        # Add '=' padding if needed
        if len(token_str) % 4:
            token_str += '=' * (4 - len(token_str) % 4)

        # Convert string to bytes
        encrypted_bytes = token_str.encode()

        # Verify signature, verify expiration, and decrypt using ``cryptography.fernet.Fernet()``
        concatenated_bytes = self.fernet.decrypt(encrypted_bytes, expiration_in_seconds)
        concatenated_str = concatenated_bytes.decode('utf-8')

        return concatenated_str
214411
def decrypt(self, txt, key):
        
        # log.debug("decrypt(txt='%s', key='%s')", txt, key)
        assert isinstance(txt, six.text_type), "txt: %s is not text type!" % repr(txt)
        assert isinstance(key, six.text_type), "key: %s is not text type!" % repr(key)

        pbkdf2_hash, crypted = txt.rsplit("$",1)

        # if not seed_generator.DEBUG and len(pbkdf2_hash)!=SALT_HASH_LEN:
        #     raise SecureJSLoginError(
        #         "encrypt error: Salt-hash %s with length %i must be length %i!" % (
        #             repr(pbkdf2_hash), len(pbkdf2_hash), SALT_HASH_LEN
        #         )
        #     )

        try:
            crypted = binascii.unhexlify(crypted)
        except (binascii.Error, TypeError) as err:
            # Py2 will raise TypeError - Py3 the binascii.Error
            raise SecureJSLoginError("unhexlify error: %s with data: %s" % (err, crypted))

        if len(crypted) != len(key):
            raise SecureJSLoginError("encrypt error: %s and '%s' must have the same length!" % (crypted, key))

        key=force_bytes(key)
        decrypted = self.xor(crypted, key)

        try:
            decrypted = force_text(decrypted)
        except UnicodeDecodeError:
            raise SecureJSLoginError("Can't decode data.")

        test = PBKDF2SHA1Hasher1().verify(decrypted, pbkdf2_hash)
        if not test:
            raise SecureJSLoginError("XOR decrypted data: PBKDF2 hash test failed")

        return decrypted
164740
public function decrypt($encryptedToken)
    {
        $decryptedToken = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($this->key), base64_decode(urldecode($encryptedToken)), MCRYPT_MODE_CBC, md5(md5($this->key))), "\0");

        if (false === $decryptedToken ) {
            throw new \InvalidArgumentException('Invalid decrypted token. Check the encryption key');
        }

        return $decryptedToken;
    }
623261
def decrypt(crypt_text) -> str:
        
        cipher = Fernet(current_app.config['KEY'])
        if not isinstance(crypt_text, bytes):
            crypt_text = str.encode(crypt_text)
        return cipher.decrypt(crypt_text).decode("utf-8")