示例#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;
  }
示例#2
0
文件: Util.java 项目: kwart/picketbox
 public static byte[] fromb64(String str) throws NumberFormatException {
   return Base64Utils.fromb64(str);
 }
示例#3
0
文件: Util.java 项目: kwart/picketbox
 // 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);
 }