Exemplo n.º 1
0
  public static String encryptText(String textToEncrypt) {
    MessageDigest messageDigest = null;
    String textEncrypted = null;

    try {
      messageDigest = MessageDigest.getInstance("SHA-512");

      byte[] textToEncryptBytes = textToEncrypt.getBytes();
      byte[] hash = messageDigest.digest(textToEncryptBytes);

      textEncrypted = Base64Utils.tob64(hash);

    } catch (NoSuchAlgorithmException noSuchAlgorithmException) {
      noSuchAlgorithmException.printStackTrace();
      // TODO: Adicionar log
    }

    return textEncrypted;
  }
Exemplo n.º 2
0
 public static byte[] fromb64(String str) throws NumberFormatException {
   return Base64Utils.fromb64(str);
 }
Exemplo n.º 3
0
 // These functions assume that the byte array has MSB at 0, LSB at end.
 // Reverse the byte array (not the String) if this is not the case.
 // All base64 strings are in natural order, least significant digit last.
 public static String tob64(byte[] buffer) {
   return Base64Utils.tob64(buffer);
 }