public Optional decrypt()

in src/main/java/com/googlesource/gerrit/plugins/lfs/auth/LfsCipher.java [63:79]


  public Optional<String> decrypt(String input) {
    if (Strings.isNullOrEmpty(input)) {
      return Optional.empty();
    }

    byte[] bytes = Base64.decode(input);
    byte[] initVector = Arrays.copyOf(bytes, IV_LENGTH);
    try {
      Cipher cipher = cipher(initVector, Cipher.DECRYPT_MODE);
      return Optional.of(
          new String(cipher.doFinal(Arrays.copyOfRange(bytes, IV_LENGTH, bytes.length)), UTF_8));
    } catch (GeneralSecurityException e) {
      log.atSevere().withCause(e).log("Exception was thrown during token verification");
    }

    return Optional.empty();
  }