This file contains hidden or 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
defmodule AES do | |
@block_size 16 | |
@secret_key "write something secret" | |
def encrypt(text) do | |
secret_key_hash = hash(@secret_key, 32) | |
# create random Initialisation Vector | |
iv = :crypto.strong_rand_bytes(16) | |
text = pad(text, @block_size) |
This file contains hidden or 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
const express = require("express"); | |
const cors = require('cors'); | |
const crypto = require('crypto-js'); | |
const PORT = process.env.PORT ?? 8080; | |
const HOST = process.env.HOST ?? '0.0.0.0'; | |
const SECRET_KEY = process.env.SECRET_KEY ?? "write something secret here"; | |
const app = express(); | |
app.use(cors()); |
This file contains hidden or 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
defmodule Crypto.AES do | |
@block_size 16 | |
@secret_key "" | |
def encrypt(text) do | |
secret_key_hash = make_hash(@secret_key, 16) | |
text = pad_pkcs7(text, @block_size) | |
encrypted_text = :crypto.block_encrypt(:aes_ecb, secret_key_hash, text) | |
Base.encode64(encrypted_text) |
This file contains hidden or 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
<?php | |
$ENCRYPTION_KEY = ''; | |
$ENCRYPTION_ALGORITHM = 'AES-128-ECB'; | |
function encrypt($plainText) { | |
global $ENCRYPTION_KEY; | |
global $ENCRYPTION_ALGORITHM; | |
$EncryptionKey = makeHash($ENCRYPTION_KEY, 16); | |
$encryptedText = openssl_encrypt($plainText, $ENCRYPTION_ALGORITHM, $EncryptionKey); |
This file contains hidden or 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
defmodule Cipher.AES do | |
@moduledoc """ | |
Functions related to encrypting and decrypting data using the Advanced | |
Encryption Standard (AES). | |
""" | |
@block_size 16 | |
@secret_key "put something secret here" | |
@doc """ |
This file contains hidden or 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
<?php | |
$ENCRYPTION_KEY = "put something secret here"; | |
$ENCRYPTION_ALGORITHM = 'AES-256-CBC'; | |
function encrypt($plain_text) { | |
global $ENCRYPTION_KEY; | |
global $ENCRYPTION_ALGORITHM; | |
$EncryptionKey = make_hash($ENCRYPTION_KEY, 32); | |
// create random Initialization Vector |
This file contains hidden or 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
def browser_open(url) do | |
win_cmd_args = ["/c", "start", String.replace(url, "&", "^&")] | |
cmd_args = | |
case :os.type() do | |
{:win32, _} -> | |
{"cmd", win_cmd_args} | |
{:unix, :darwin} -> | |
{"open", [url]} |
This file contains hidden or 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
// [0, 0, 0] | |
Array(3).fill(0); | |
Array.from(Array(3), () => 0); | |
// [0, 2, 4, 6, 8] | |
Array.from(Array(5), (_, index) => index * 2); | |
// Array of 5 random numbers | |
Array.from(Array(5), Math.random()); |
This file contains hidden or 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
# Using for construct | |
# [0, 0, 0] | |
for _x <- 0..2, do: 0 | |
# [0, 2, 4, 6, 8] | |
for x <- 0..4, do: x * 2 | |
# List of 5 random numbers | |
for _x <- 0..4, do: System.unique_integer([:positive]) |
This file contains hidden or 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
const fs = require('fs') | |
const axios = require('axios'); | |
const Papa = require("papaparse"); | |
fs.readFile('sample.csv', 'utf8', (err, data) => { | |
if (err) { | |
return console.error(err) | |
} | |
const [headers, ...parsedCSVData] = Papa.parse(data).data |