This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { cipher, util } from "node-forge"; | |
# npm i --save-dev @types/node-forge | |
const secretKey = "12a97d88d634afdf9f4da5bd35223f01"; | |
const iv = "5bf11a0951fa"; | |
# Doing encryption | |
const cipherGCM = cipher.createCipher("AES-GCM", this.secretKey); | |
cipherGCM.start({iv: this.iv}); | |
cipherGCM.update(util.createBuffer("Test message")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
security: | |
authorization: "enabled" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// Deps: | |
/// ring = "0.16.20" | |
/// base64 = "0.13.1" | |
/// Rust version 1.64.0 | |
use ring::aead::{AES_256_GCM, UnboundKey}; | |
use base64::{encode, decode}; | |
use ring::{aead, error, rand}; | |
struct OneNonceSequence(Option<aead::Nonce>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from redis import Redis, exceptions | |
import time | |
from uuid import uuid4 | |
class DistributedLock(object): | |
def __init__(self, redis_client, lock_name, owner_id=None, lock_ttl=10, poll_time=1): | |
""" | |
:param redis_client: The redis client, can be strict or normal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import base64 | |
import hashlib | |
from Crypto import Random | |
from Crypto.Cipher import AES | |
class AESCipher(object): | |
def __init__(self, key): | |
self.key = hashlib.sha256(key.encode()).digest() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.crypto.Cipher; | |
import javax.crypto.spec.IvParameterSpec; | |
import javax.crypto.spec.SecretKeySpec; | |
import java.util.Base64; | |
import java.security.SecureRandom; | |
import java.security.MessageDigest; | |
import java.io.UnsupportedEncodingException; | |
import java.security.NoSuchAlgorithmException; | |
import javax.crypto.IllegalBlockSizeException; | |
import javax.crypto.NoSuchPaddingException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE DATABASE testdb | |
GRANT ALL PRIVILEGES ON testdb.* To 'testuser'@'%' IDENTIFIED BY 'plainPassword'; |