Skip to content

Instantly share code, notes, and snippets.

@vihatsoft
vihatsoft / AesCipher.java
Created May 28, 2021 03:46 — forked from demisang/AesCipher.java
AES/CBC/PKCS5Padding encrypt/decrypt PHP and JAVA example classes
import android.support.annotation.Nullable;
import android.util.Base64;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
@vihatsoft
vihatsoft / getTimeStampDifference.php
Last active June 28, 2021 13:28
PHP get two timestamp difference in years, months, days, hours, minutes and second
<?php
// Function to get difference of two timestamp into years, months, days, hours, minutes and seconds
function getTimeDifference($datetime1, $datetime2, $inShort = true) {
$datetime1 = new DateTime(date('Y-m-d H:i:s', $datetime1));//start time
$datetime2 = new DateTime(date('Y-m-d H:i:s', $datetime2));//end time
$interval = $datetime1->diff($datetime2);
$formats_array = array( "years" => "%Y", "months" => "%m", "days" => "%d", "hours" => "%H", "minutes" => "%i", "seconds" => "%s" );
$return_time = "";
foreach($formats_array as $key => $value ) {
  1. First get to the existing directory
    $ cd my/folder/

  2. Now start a new git repository
    $ git init

  3. Identify if the current elements on the directory are needed or not and add them to the .gitignore file. When ready...
    $ vim .gitignore

  4. When ready create the first commit on the server

@vihatsoft
vihatsoft / openssl_encrypt_decrypt.php
Created March 2, 2022 11:54 — forked from joashp/openssl_encrypt_decrypt.php
Simple PHP encrypt and decrypt using OpenSSL
<?php
/**
* simple method to encrypt or decrypt a plain text string
* initialization vector(IV) has to be the same when encrypting and decrypting
*
* @param string $action: can be 'encrypt' or 'decrypt'
* @param string $string: string to encrypt or decrypt
*
* @return string
*/