public static String encrypt ( final String aText , final String aSalt ) throws NullPointerException , IOException { Objects . requireNonNull ( aText , LOGGER . getI18n ( "Text to encrypt is null" ) ) ; Objects . requireNonNull ( aSalt , LOGGER . getI18n ( "Salt to encrypt with is null" ) ) ; try { final MessageDigest digest = MessageDigest . getInstance ( "SHA" ) ; final String saltedText = aText + aSalt ; digest . update ( saltedText . getBytes ( "UTF-8" ) ) ; return Base64 . encodeBytes ( digest . digest ( ) ) ; } catch ( final NoSuchAlgorithmException details ) { throw new I18nRuntimeException ( details ) ; // programming error } catch ( final UnsupportedEncodingException details ) { throw new I18nRuntimeException ( details ) ; // programming error } }
Encrypts the supplied text using the supplied salt .