Skip to content

Instantly share code, notes, and snippets.

View dchest's full-sized avatar
☮️

Dmitry Chestnykh dchest

☮️
View GitHub Profile
<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;
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:
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);
(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);
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
@dchest
dchest / gist:6740853
Last active December 24, 2015 03:59
StartSSL's reply

After trying to get a free certificate from StartSSL for my personal blog "sellme.ru", and my request being declined because the domain contains a word "sell", here's what StartSSL representative told me:

"We have no problem with issuing Class 1 certs for a domains owned by commercial companies or individuals, there however shouldn't be commercial activity on the web-sites they request certificates for. And their domain/sub-domain name shouldn't contain any "commercial" words. For example these requests pay.domain.com, sell.domain.com, subdomain.sellme.ru would be declined and it doesn't matter whether there is some commercial activity or not."

// Package secretentropy wraps any random Reader to produce a random Reader
// that mixes a secret into its output.
//
// Example usage with DSA where priv is *dsa.PrivateKey, and message is a
// message byte slice we're going to sign:
//
// srand := secretentropy.NewReader(rand.Reader, privateKey.X.Bytes(), message)
// r, s, err := dsa.Sign(srand, priv, messageHash)
//
package secretentropy

Technical details

I. Generating seed

  1. Generate 16-byte Seed using CSPRNG or a source of truly random numbers.
  2. Output Seed for a user and/or a program to store.
@dchest
dchest / gist:5229268
Created March 23, 2013 20:39
Forgot password
https://clck.yandex.ru/redir/dtype=stred/pid=2/cid=72021/path=restore.macstore.en/*data=url%3Dhttps%253A%252F%252Fpassport.yandex.com%252Fpassport%253Fmode%253Drestore%2526from%253Dcloud
https://clck.yandex.ru/redir/dtype=stred/pid=2/cid=72021/path=register.macstore.en/*data=url%3Dhttps%253A%252F%252Fpassport.yandex.com.tr%252Fpassport%253Fmode%253Dregister%2526from%253Dcloud%2526origin%253Dmacstore.yandex.en%2526retpath%253Dhttp%253A%252F%252Fdisk.yandex.com%252F%253Forigin%253Dmacstore.yandex.en