From 041886c20a28823e3ad50679e6e52272bd2a3ae5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Thu, 4 Aug 2011 01:49:30 +0200 Subject: JCryption add Fixnum#to_bytes --- lib/ayk/jcryption.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ayk/jcryption.rb b/lib/ayk/jcryption.rb index ab60d34..6e4d1ed 100644 --- a/lib/ayk/jcryption.rb +++ b/lib/ayk/jcryption.rb @@ -42,6 +42,18 @@ def Math.power_modulo(b, p, m) end end # +class Fixnum + def to_bytes + str = '' + int = self + while int!=0 do + int,r = int.divmod 256 + str += r.chr + end + str + end +end +# class Bignum # class << self -- cgit v1.1-2-g2b99