summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2011-08-04 01:49:30 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2011-08-04 01:49:30 +0200
commit041886c20a28823e3ad50679e6e52272bd2a3ae5 (patch)
tree771347097e76f194cd927a9037429af469034b04
parent02382433248cb0b9262a8561e292386e949f8d61 (diff)
downloadayk-041886c20a28823e3ad50679e6e52272bd2a3ae5.zip
ayk-041886c20a28823e3ad50679e6e52272bd2a3ae5.tar.gz
JCryption add Fixnum#to_bytes
-rw-r--r--lib/ayk/jcryption.rb12
1 files changed, 12 insertions, 0 deletions
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