Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
@dchest
dchest / pure-tweaks.css
Last active April 21, 2019 11:50
PureCSS tweaks
/*
dchest's PureCSS Tweaks
https://gist.github.com/dchest/500746c2e41baaafcab3
*/
* {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
@dchest
dchest / main.swift
Created February 4, 2015 10:08
Swift HashDoS
import Foundation
func randomStringWithLength (len : Int) -> NSString {
// from http://stackoverflow.com/a/26845710/311196
let letters : NSString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
var randomString : NSMutableString = NSMutableString(capacity: len)
for (var i=0; i < len; i++){

Keybase proof

I hereby claim:

  • I am dchest on github.
  • I am dchest (https://keybase.io/dchest) on keybase.
  • I have a public key whose fingerprint is F466 022B 936F 90F0 FCBB 50BA BE06 B1CD 3F41 D32D

To claim this, I am signing this object:

@dchest
dchest / rc4.js
Last active August 29, 2015 14:08
function rc4(f,F,g,G){for(var U=256,b=[],c=a=0,d;U>a;a++)b[a]=a;for(a=0;U>a;a++)c=(c+b[a]+f[a%F])%U,d=b[a],b[a]=b[c],b[c]=d;for(var e=c=a=0;e<G;e++)a++,a%=U,c+=b[a],c%=U,d=b[a],b[a]=b[c],b[c]=d,g[e]=b[(b[a]+b[c])%U]}
// Usage:
//
var key = [75, 101, 121]; // input bytes: "Key"
var out = new Array(10); // place for keystream bytes
rc4(key, key.length, out, out.length); // out now contains keystream: [235, 159, 119, 129, 183, 52, 202, 114, 167, 25]
@dchest
dchest / asmcrypto-sha512.js
Created October 15, 2014 20:37
asmCrypto.js SHA512 - from https://github.com/vibornoff/asmcrypto.js built: grunt --with sha512
!function(a,b){"use strict";function c(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function d(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function e(){var a=Error.apply(this,arguments);this.message=a.message,this.stack=a.stack}function f(a){for(var b=a.length,c=new Uint8Array(b),d=0;b>d;d++){var e=a.charCodeAt(d);if(e>>>8)throw new Error("Wide characters are not allowed");c[d]=e}return c}function g(a){for(var b="",c=0;c<a.length;c++)b+=String.fromCharCode(a[c]);return b}function h(a){for(var b=(a.byteLength||a.length)/a.length,c="",d=0;d<a.length;d++){var e=a[d].toString(16);e.length<2*b&&(c+="00000000000000".substr(0,2*b-e.length)),c+=e}return c}function i(a){return btoa(g(a))}function j(a){return"string"==typeof a}function k(a){return a instanceof ArrayBuffer}function l(a){return a instanceof Uint8Array}function m(){return this.result=null,this.pos=0,this.len=0,this.asm.reset(),this}function n(a){if(null!==this.result)throw new c("state mus
@dchest
dchest / uuid.go
Last active August 29, 2015 14:06
// Written by Dmitry Chestnykh. Public domain.
// Package uuid provides Universally unique identifiers.
package uuid
import (
"crypto/rand"
"fmt"
"io"
)
Downloading/unpacking deadlock
Downloading deadlock-0.1.1.tar.gz
Running setup.py (path:/tmp/pip_build_root/deadlock/setup.py) egg_info for package deadlock
Traceback (most recent call last):
File "<string>", line 17, in <module>
File "/tmp/pip_build_root/deadlock/setup.py", line 1, in <module>
import deadlock
ImportError: No module named deadlock
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]" />
<script src="//fb.me/react-0.10.0.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
@dchest
dchest / scalarmult_test_input.go
Last active August 29, 2015 14:02
This program generates random test vectors for curve25519 scalarmult based on Go's NaCl implementation
package main
import (
"fmt"
"crypto/rand"
"code.google.com/p/go.crypto/nacl/box"
"code.google.com/p/go.crypto/curve25519"
)
func main() {
--- tweetnacl-20131229.c 2013-12-29 12:06:54.000000000 +0100
+++ tweetnacl-20140427.c 2014-04-27 11:17:16.000000000 +0200
@@ -22,7 +22,7 @@
Y = {0x6658, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666, 0x6666},
I = {0xa0b0, 0x4a0e, 0x1b27, 0xc4ee, 0xe478, 0xad2f, 0x1806, 0x2f43, 0xd7a7, 0x3dfb, 0x0099, 0x2b4d, 0xdf0b, 0x4fc1, 0x2480, 0x2b83};
-static u32 L32(u32 x,int c) { return (x << c) | (x >> (32 - c)); }
+static u32 L32(u32 x,int c) { return (x << c) | ((x&0xffffffff) >> (32 - c)); }
static u32 ld32(const u8 *x)