Decrypt a string

@param text
the text to decrypt
@return the decrypted text
@throws Exception
480156
public String decryptText(String text)
	throws Exception
	{
		return new String(this.decrypt(toBytesFromByteText(text)), IO.CHARSET);

	}
977210
public static final String decrypt(String secretKey, String encryptedText) {
        if (encryptedText == null) {
            return null;
        }
        if (encryptedText.startsWith("$CRYPT::")) { //$NON-NLS-1$
            byte[] decoded = Base64.decodeBase64(encryptedText.substring(8));
            Cipher cipher;
            try {
                SecretKeySpec skeySpec = keySpecFromSecretKey(secretKey);
                
                cipher = Cipher.getInstance("AES"); //$NON-NLS-1$
                cipher.init(Cipher.DECRYPT_MODE, skeySpec);
            } catch (NoSuchAlgorithmException | NoSuchPaddingException | InvalidKeyException e) {
                throw new RuntimeException(e);
            }
            try {
                return new String(cipher.doFinal(decoded));
            } catch (IllegalBlockSizeException | BadPaddingException e) {
                throw new RuntimeException(e);
            }
        } else {
            return encryptedText;
        }
    }
542907
public static JsonStructure decode(String text) {
        if (text == null) throw new IllegalArgumentException("text cannot be null");
        StringReader sr = new StringReader(text);
        JsonReader r = new JsonReader(sr);
        return decodeFully(r);
    }
776910
def decrypt(encrypted)
      fail ArgumentError, 'No cipher text supplied.' if encrypted.nil? || encrypted.empty?

      matches = CIPHER_PATTERN.match(encrypted)

      fail ArgumentError, 'Cipher text has an unsupported format.' if matches.nil?

      cipher = self.class.cipher
      cipher.decrypt
      cipher.key = Base64.decode64(@key)
      cipher.iv = Base64.decode64(matches[1])
      decrypted = cipher.update(Base64.decode64(matches[2]))

      decrypted << cipher.final
    end
1035191
def decrypt(self, ciphertext):
        """"""

        # Separate keys from message.
        enc_key = ciphertext[:3]
        message = ciphertext[3:-3]
        grundstellung = ciphertext[-3:]

        # Decrypt message key.
        self.machine.set_display(grundstellung)
        msg_key = self.machine.process_text(enc_key)
        # Decrpyt message.
        self.machine.set_display(msg_key)
        return self.machine.process_text(message)
816940
public Object parseText(String text) {
        if (text == null || "".equals(text)) {
            throw new IllegalArgumentException("Text must not be null");
        }
        return createParser().parse(text);
    }
912937
public <V> V convertFrom(final String text) {
        if (text == null) return null;
        return (V) convertFrom(Utility.charArray(text));
    }
92352
public final String decryptString(SecretKey sharedKey, byte[] encryptedString) {
        logger.entry();
        try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedString);
                ByteArrayOutputStream output = new ByteArrayOutputStream()) {
            decryptStream(sharedKey, input, output);
            output.flush();
            String string = output.toString("UTF-8");
            logger.exit();
            return string;
        } catch (IOException e) {
            // should never happen!
            RuntimeException exception = new RuntimeException("An unexpected exception occured while trying to decrypt a string.", e);
            logger.error(exception.toString());
            throw exception;
        }
    }
533452
protected String decrypt(String encryptedStr) throws Exception {
        String[] split = encryptedStr.split(":");
        checkTrue(split.length == 3, "Wrong format of the encrypted variable (" + encryptedStr + ")");
        byte[] salt = Base64.getDecoder().decode(split[0].getBytes(UTF8_CHARSET));
        checkTrue(salt.length == saltLengthBytes, "Salt length doesn't match.");
        int iterations = Integer.parseInt(split[1]);
        byte[] encryptedVal = Base64.getDecoder().decode(split[2].getBytes(UTF8_CHARSET));
        return new String(transform(Cipher.DECRYPT_MODE, encryptedVal, salt, iterations), UTF8_CHARSET);
    }
1016643
public static String generateShaHash(String text) {
		try {
			MessageDigest digest = MessageDigest.getInstance(SHA_ALGORITHM);
			byte[] bytes = text.getBytes(UTF_8);
			bytes = digest.digest(bytes);
			return toHexEncode(bytes);
		} catch (Exception e) {
			throw new UnexpectedException(e);
		}
	}
1349789
public static byte[] AesDecryptByBase64Str(String base64String,byte[] decryptKey) throws Exception {
		byte[] content=Base64Decode(base64String);
		return AesDecryptByBytes(content, decryptKey);
	}
479662
private static String unescapeLiteral(final String text) {

        if (text == null) {
            return null;
        }

        StringBuilder strBuilder = null;

        final int max = text.length();

        int readOffset = 0;
        int referenceOffset = 0;

        char c;

        for (int i = 0; i < max; i++) {

            c = text.charAt(i);

            /*
             * Check the need for an unescape operation at this point
             */

            if (c != ESCAPE_PREFIX || (i + 1) >= max) {
                continue;
            }

            if (c == ESCAPE_PREFIX) {

                switch (text.charAt(i + 1)) {
                    case '\'': c = '\''; referenceOffset = i + 1; break;
                    case '\\': c = '\\'; referenceOffset = i + 1; break;
                    // We weren't able to consume any valid escape chars, just not consider it an escape operation
                    default: referenceOffset = i; break;
                }

            }


            /*
             * At this point we know for sure we will need some kind of unescape, so we
             * can increase the offset and initialize the string builder if needed, along with
             * copying to it all the contents pending up to this point.
             */

            if (strBuilder == null) {
                strBuilder = new StringBuilder(max + 5);
            }

            if (i - readOffset > 0) {
                strBuilder.append(text, readOffset, i);
            }

            i = referenceOffset;
            readOffset = i + 1;

            /*
             * Write the unescaped char
             */
            strBuilder.append(c);

        }


        /*
         * -----------------------------------------------------------------------------------------------
         * Final cleaning: return the original String object if no unescape was actually needed. Otherwise
         *                 append the remaining escaped text to the string builder and return.
         * -----------------------------------------------------------------------------------------------
         */

        if (strBuilder == null) {
            return text;
        }

        if (max - readOffset > 0) {
            strBuilder.append(text, readOffset, max);
        }

        return strBuilder.toString();

    }
440474
def decrypt(text):
    ''
    crypt = EncryptionAlgorithm.new(_get_encryption_key())
    return crypt.decrypt(text).rstrip(ENCRYPT_PAD_CHARACTER)
728773
@Override
    public String encode( String text ) {
        try {
            byte[] hash = SecureHash.getHash(algorithm, text.getBytes());
            String result = Base64.encodeBytes(hash);
            return result.length() < maxLength ? result : result.substring(0, maxLength);
        } catch (NoSuchAlgorithmException e) {
            return text;
        }
    }
117832
private String decrypt( final String maybeEncryptedPassphrase ) {
        if (maybeEncryptedPassphrase == null) {
            return null;
        }

        try {
            final String decrypted = secDispatcher.decrypt(maybeEncryptedPassphrase);
            if (maybeEncryptedPassphrase.equals(decrypted)) {
                console.info("Passphrase was not encrypted");
            } else {
                console.info("Passphrase was successfully decrypted");
            }
            return decrypted;
        } catch (SecDispatcherException e) {
            console.warn("Unable to decrypt passphrase: " + e.getMessage());
        }

        return maybeEncryptedPassphrase;
    }
667761
public static String decrypt(String key, String hexStr)
    {
        try
        {
            return new String(createAesDecryptionCipher(key).doFinal(ByteUtilities.decode(hexStr)));
        }
        catch (Exception e)
        {
            throw new IllegalStateException("Error occurred decrypting data", e);
        }
    }
1036144
public static String encrypt(Key key, String content) throws Exception {
        try {
            Cipher cipher = Cipher.getInstance(CRYPTO_ALGORITHM);
            cipher.init(Cipher.ENCRYPT_MODE, key);
            return Base64.encodeBase64String(cipher.doFinal(content.getBytes()));
        } catch (Exception e) {
            log.error("Error while encrypting", e);
            throw e;
        }
    }