Skip to content

Instantly share code, notes, and snippets.

View spiegel-im-spiegel's full-sized avatar
😀
being hired

Spiegel spiegel-im-spiegel

😀
being hired
View GitHub Profile
@spiegel-im-spiegel
spiegel-im-spiegel / app.js
Last active August 29, 2015 14:15
「紙芝居」用の簡単 HTTP サーバを立てる ref: http://qiita.com/spiegel-im-spiegel/items/38b2e0b16ffc4f3548b3
var connect = require('connect');
var serveStatic = require('serve-static');
var port = 3000;
connect().use(serveStatic(__dirname)).listen(port);
console.log('Server has started at http://localhost:' + port);
/**
* 任意の桁数に切り取った文字列を返す
* 桁数に足りない場合は任意の文字で左側を埋める
*
* @param {String} val 元の文字
* @param {Number} num 桁数
* @param {String} pad 文字埋めに使用する文字列
* @return {String} 作成した文字列
*/
var padSlice = function(val, num, pad) {
@spiegel-im-spiegel
spiegel-im-spiegel / freak.md
Last active August 29, 2015 14:16
RSA-to-EXPORT_RSA ダウングレード攻撃に関する覚え書き

RSA-to-EXPORT_RSA ダウングレード攻撃に関する覚え書き

または Factoring attack on RSA-EXPORT Keys(FREAK)。 SSL/TLS で「輸出グレード暗号」を受け入れてしまう実装あり。

概要

中間者攻撃(Man-in-the-Middle Attack)により Web サーバへの要求を「輸出グレード暗号(RSA_EXPORT cipher suites)」に書き換えられると、サーバ・クライアントともに「輸出グレード暗号」を受け入れてしまう。

「輸出グレード暗号」の例としては以下の暗号スイートが挙げられる。

C:>go version
go version go1.4.2 windows/amd64
@spiegel-im-spiegel
spiegel-im-spiegel / file1.txt
Last active August 29, 2015 14:19
はじめての Go 言語 (on Windows) その2 ref: http://qiita.com/spiegel-im-spiegel/items/047a9bd6436e6391ddd4
C:>go run prime01.go
100 以下の素数: 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
5.0002ms 経過
@spiegel-im-spiegel
spiegel-im-spiegel / file1.txt
Last active August 29, 2015 14:20
はじめての Go 言語 (on Windows) その4 ref: http://qiita.com/spiegel-im-spiegel/items/556166b6631c0369754f
C:>go run string1.go
nihongo = 9 bytes : e6 97 a5 e6 9c ac e8 aa 9e
@spiegel-im-spiegel
spiegel-im-spiegel / file0.txt
Last active August 29, 2015 14:21
はじめての Go 言語 (on Windows) その5 ref: http://qiita.com/spiegel-im-spiegel/items/e743d63ef5165d750eff
\begin{aligned}
y & = Y + \left\lfloor \frac{M - 3}{12} \right\rfloor \\
m & = \left( 12 + \left( M - 3 \right) \right) \bmod 12 \\
d & = D - 1 \\
MJD & = \left\lfloor 365.25y \right\rfloor + \left\lfloor \frac{y}{400} \right\rfloor - \left\lfloor \frac{y}{100} \right\rfloor + \left\lfloor 30.60m + 0.5 \right\rfloor + d - 678881 \\
JD & = MJD + 2400000.5
\end{aligned}
@spiegel-im-spiegel
spiegel-im-spiegel / file1.txt
Last active August 29, 2015 14:21
はじめての Go 言語 (on Windows) その6 ref: http://qiita.com/spiegel-im-spiegel/items/404871d2bafd22bdbb90
C:>go run jd4.go 1969 12 31
1969-12-31 00:00:00 +0000 UTC
MJD = 40586日
C:>go run jd4.go 1970 1 1
1970-01-01 00:00:00 +0000 UTC
MJD = 40587日
C:>go run jd4.go 2015 1 1
2015-01-01 00:00:00 +0000 UTC
language: go
go:
- 1.4
script:
- go test -v ./...
package modjulian_test
import (
"fmt"
"github.com/spiegel-im-spiegel/astrocalc/modjulian"
"time"
)
func ExampleDayNumber() {
t := time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)