Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
0
#103 bad length: iciF0y
#366 bad length: oAtify4
#764 bad length: 3diFy
#823 bad length: i4fy
1000
#1311 bad length: ci0fy
#1601 bad length: e6uSify
#1628 bad length: Tun0ify
#1786 bad length: tif3y
(function() {
var ps = {};
for (var i = 0; i < 1000000; i++) {
var p = GPW.pronounceable(7);
if (p.length != 8) {
console.log("#"+i+" bad length: ", p);
}
if (ps[p]) {
console.log("#"+i+" collission!", p);
function getRandomBytes(length) {
var bytes = new Uint8Array(length);
window.crypto.getRandomValues(bytes);
return bytes;
}
function generatePassword(length) {
// To avoid modulo bias, alphabet length must conform to 256 % length == 0, e.g. 64.
var alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_@'.split('');
var bytes = getRandomBytes(length);
Problem:
Peak electricity consumption leads to downtime.
The majority of people don't want such downtime.
Proposed solution:
Switching to compact fluorescent lamp will reduce peak consumption.
Ways to implement solution:
<script>
// https://github.com/dchest/tweetnacl-js/issues/12
var gf = function() { return [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]; };
var D2 = [61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222];
function car25519(o) {
var c;
for (var i = 0; i < 16; i++) {
o[i] += 65536;
--- 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)
@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() {
<!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>
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):
@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"
)