Skip to content

Instantly share code, notes, and snippets.

/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';
@amit08255
amit08255 / rc4.js
Created June 16, 2021 07:42 — forked from farhadi/rc4.js
RC4 encryption in javascript and php
/*
* RC4 symmetric cipher encryption/decryption
*
* @license Public Domain
* @param string key - secret key for encryption/decryption
* @param string str - string to be encrypted/decrypted
* @return string
*/
function rc4(key, str) {
var s = [], j = 0, x, res = '';
// use (16 chars of) 'password' to encrypt 'plaintext'
function encrypt(plaintext, password) {
var v = new Array(2), k = new Array(4), s = "", i;
plaintext = escape(plaintext); // use escape() so only have single-byte chars to encode
// build key directly from 1st 16 chars of password
for (var i=0; i<4; i++) k[i] = Str4ToLong(password.slice(i*4,(i+1)*4));
@amit08255
amit08255 / conventional-commit-format.md
Last active December 25, 2020 19:38
Conventional Commit Format

Commit Message Format

We have very precise rules over how our Git commit messages must be formatted. This format leads to easier to read commit history.

Each commit message consists of a header, a body, and a footer.

<header>
@amit08255
amit08255 / gist:37deb39fc8ae3373f645652307815bb6
Created December 17, 2020 19:57 — forked from EvanHahn/gist:2587465
Caesar shift in JavaScript
/*
JavaScript Caesar shift
by Evan Hahn (evanhahn.com)
"Encrypt" like this:
caesarShift('Attack at dawn!', 12); // Returns "Mffmow mf pmiz!"
And "decrypt" like this:
@amit08255
amit08255 / XORCipher.js
Created December 17, 2020 19:56 — forked from sukima/XORCipher.js
A Super simple encryption cipher using XOR and Base64 in JavaScript
// XORCipher - Super simple encryption using XOR and Base64
//
// Depends on [Underscore](http://underscorejs.org/).
//
// As a warning, this is **not** a secure encryption algorythm. It uses a very
// simplistic keystore and will be easy to crack.
//
// The Base64 algorythm is a modification of the one used in phpjs.org
// * http://phpjs.org/functions/base64_encode/
// * http://phpjs.org/functions/base64_decode/
@amit08255
amit08255 / hide-scrollbar-mixin.scss
Created August 19, 2020 07:28 — forked from pandauxstudio/hide-scrollbar-mixin.scss
Sass mixin to hide scrollbar in Chrome, Firefox, Safari and IE.
@mixin hideScrollbar {
// https://blogs.msdn.microsoft.com/kurlak/2013/11/03/hiding-vertical-scrollbars-with-pure-css-in-chrome-ie-6-firefox-opera-and-safari/
// There is a CSS rule that can hide scrollbars in Webkit-based browsers (Chrome and Safari).
&::-webkit-scrollbar {
width: 0 !important
}
// There is a CSS rule that can hide scrollbars in IE 10+.
-ms-overflow-style: none;
// Use -ms-autohiding-scrollbar if you wish to display on hover.
@amit08255
amit08255 / remove_duplicates.js
Created June 5, 2020 05:05 — forked from lmfresneda/remove_duplicates.js
Remove duplicates from an array of objects in javascript
// FUN METHOD
/**
* Remove duplicates from an array of objects in javascript
* @param arr - Array of objects
* @param prop - Property of each object to compare
* @returns {Array}
*/
function removeDuplicates( arr, prop ) {
let obj = {};
return Object.keys(arr.reduce((prev, next) => {
@amit08255
amit08255 / deepCopy.js
Created March 25, 2020 05:01 — forked from c7x43t/deepCopy.js
Deep Copy an object very fast
// deep copy:
// String, Number, undefined, null, Set, Map, typed Array, Object, Boolean, RegExp, Date, ArrayBuffer, Node
// Functions, Properties of types: (Primitive, Symbol)
// shallow copy (by reference):
// WeakMap, WeakSet, Symbol
// increased compatibility: IE, Node
var $jscomp = $jscomp || {};
$jscomp.scope = {};
$jscomp.ASSUME_ES5 = !1;
$jscomp.defineProperty = $jscomp.ASSUME_ES5 || "function" == typeof Object.defineProperties ? Object.defineProperty : function(a, b, c) {