差分
この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン 次のリビジョン | 前のリビジョン | ||
programming:python:rfc5952 [2012/12/05 22:16] yuki |
programming:python:rfc5952 [2021/05/22 18:50] yuki 削除 |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
====== RFC5952 ====== | ====== RFC5952 ====== | ||
- | 簡単にバイナリ to [[http://tools.ietf.org/rfc/rfc5952.txt|RFC5952]]表記な文字列に変換してみるコード。全部ちゃんと動くのか若干自信ない。 | + | 文字列とバイナリ表現の相互変換用のスクリプト。 |
+ | |||
+ | こんな感じで使う。 | ||
+ | |||
+ | >>> import rfc5952 | ||
+ | >>> binary = '\x20\x01\x0d\xb8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01' | ||
+ | >>> rfc5952.inet6_ntoa(binary) | ||
+ | '2001:db8::1' | ||
+ | >>> string = "2001:db8:1f1f:90::82" | ||
+ | >>> rfc5952.inet6_aton(string) | ||
+ | ' \x01\r\xb8\x1f\x1f\x00\x90\x00\x00\x00\x00\x00\x00\x00\x82' | ||
+ | |||
+ | Bitbucketで公開してます。 | ||
+ | |||
+ | * https://bitbucket.org/ainoniwa/rfc5952/src/dcb12192d35f730d843f2922e0d0b75f702d2092/rfc5952.py | ||
- | こっちを見てください。 | ||
- | [[https://bitbucket.org/ainoniwa/rfc5952/src/dcb12192d35f730d843f2922e0d0b75f702d2092/rfc5952.py]] |