From 3ee291cce4dfcc7d423c1060509f3f1c41a89b1c Mon Sep 17 00:00:00 2001 From: couchot Date: Fri, 14 Sep 2012 11:48:51 +0200 Subject: [PATCH 1/1] reprise --- stc/exp/raphus/bbs.py | 4 +- stc/exp/raphus/sobel555_for_ensemble.py | 65 +++++++++---------------- 2 files changed, 26 insertions(+), 43 deletions(-) diff --git a/stc/exp/raphus/bbs.py b/stc/exp/raphus/bbs.py index f2e9fd8..88a5e6d 100644 --- a/stc/exp/raphus/bbs.py +++ b/stc/exp/raphus/bbs.py @@ -116,9 +116,9 @@ class BlumBlumShub(object): x = x>>1 return q - def next(self, numBits): + def next(self, numBits=160): self.state = (self.state**2) % self.n - return float(self.state)/self.n + return self.state def random(self): self.state = (self.state**2) % self.n diff --git a/stc/exp/raphus/sobel555_for_ensemble.py b/stc/exp/raphus/sobel555_for_ensemble.py index 1a7f7c6..3a1e5f5 100644 --- a/stc/exp/raphus/sobel555_for_ensemble.py +++ b/stc/exp/raphus/sobel555_for_ensemble.py @@ -13,6 +13,12 @@ from bbs import * infinity = 1000000000 +M=18532395500947174450709383384936679868383424444311405679463280782405796233163977*39688644836832882526173831577536117815818454437810437210221644553381995813014959 +# M clef +X=18532395500947174450709383384936679868383424444311 +# X clef + + @@ -377,8 +383,8 @@ def compute_list_bit_to_change(threshold,processed): def compute_filter_canny(level,image,MsgLen): bbs = BlumBlumShub(); - bbs.setN(18532395500947174450709383384936679868383424444311405679463280782405796233163977*39688644836832882526173831577536117815818454437810437210221644553381995813014959) - bbs.setSeed(18532395500947174450709383384936679868383424444311) + bbs.setN(M) + bbs.setSeed(X) level2=level.copy() level2= array(level2.getdata()).flatten() @@ -495,6 +501,13 @@ def compute_filter_canny(level,image,MsgLen): def mystego(filein, fileout): + + bbs = BlumBlumShub(); + bbs.setN(M) + bbs.setSeed(X) + + + dd = im.open(filein) dd = dd.convert('RGB') red, green, blue = dd.split() @@ -506,51 +519,22 @@ def mystego(filein, fileout): message="Salut christophe, arrives tu à lire ce message? normalement tu dois lire cela. Bon voici un test avec un message un peu plus long. Bon j'en rajoute pour voir. Ce que j'écris est très original... Bref, je suis un poete Salut christophe, arrives tu à lire ce message? normalement tu dois lire cela." + """ + message = "" + for c in [x if x==0 else 1 for x in im.open("invader.png").getdata()]: + message +=str(c) + + print message + """ - message=message[0:len(message)/1] leng_msg=len(message) - message=message+((leng_msg+7)/8*8-leng_msg)*" " - leng_msg=len(message) - - leng='%08d'%len(message) - - - - - len_leng=len(leng) - leng_error=int(len_leng) - leng_cor=leng - List_pack=a2b_list(leng_cor) - - - - - - [List_bit_to_change,Weight]=compute_filter_canny(level,dd,leng_msg) - level= array(level.getdata()).flatten() - - - bit_to_read=1 - - - - - M=18532395500947174450709383384936679868383424444311405679463280782405796233163977*39688644836832882526173831577536117815818454437810437210221644553381995813014959 - # M clef - X=18532395500947174450709383384936679868383424444311 - # X clef - - - - l=0 List_random=[] while len(List_random)= 2 index = min(int(alpha),9) H_hat2 = { -- 2.39.5