Skip to content

Instantly share code, notes, and snippets.

@chanchal-357
chanchal-357 / crypto_util_AES_GCM.py
Created October 18, 2021 07:52
Python code implementing AES-GCM cryptography, using random IV and salt
import base64
import hashlib
from Cryptodome.Cipher import AES # from pycryptodomex v-3.10.4
from Cryptodome.Random import get_random_bytes
HASH_NAME = "SHA256"
IV_LENGTH = 12
ITERATION_COUNT = 65536
KEY_LENGTH = 32
@chanchal-357
chanchal-357 / CryptoUtilAesGcm.java
Last active October 2, 2024 13:39
Java code implementing AES-GCM cryptography, using random IV and salt
import javax.crypto.Cipher;
import javax.crypto.NoSuchPaddingException;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
@chanchal-357
chanchal-357 / crypto_util_AES_CBC.py
Last active October 12, 2023 22:47
AES CBC Encrypt-Decrypt using random IV (python 3.9)
import base64
import hashlib
from Cryptodome.Cipher import AES # from pycryptodomex v-3.10.4
from Cryptodome.Random import get_random_bytes
HASH_NAME = "SHA256"
IV_LENGTH = 16
ITERATION_COUNT = 65536
KEY_LENGTH = 32
@chanchal-357
chanchal-357 / CryptoUtilAesCbc.java
Last active October 18, 2021 07:33
AES CBC Encrypt-Decrypt using random IV (java 8)
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.ByteBuffer;
import java.security.SecureRandom;
import java.security.spec.KeySpec;
import java.util.Arrays;
@chanchal-357
chanchal-357 / async.html
Created October 4, 2018 10:38
Jquery Async using Promise
<html>
<head>
<title> Thai Text only </title>
</head>
<link href="style.css" rel="stylesheet" type="text/css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script>
$(document).ready(function(){
$('.thai').on('input', function (event) {
this.value = this.value.replace(/[^\u0E00-\u0E7F0-9]/g, '');
@chanchal-357
chanchal-357 / BasicDAO.java
Last active August 8, 2018 02:50
JQGrid java Backend
package com.test.basic.dao;
import com.test.model.BaseDO;
import com.test.model.GridRequest;
import com.test.model.GridResponse;
public interface BasicDAO {
public BaseDO get(Class klass, Number id);