AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi Chinesischer Restsatz, pseudocode gesucht
Thema durchsuchen
Ansicht
Themen-Optionen

Chinesischer Restsatz, pseudocode gesucht

Ein Thema von qwertz543221 · begonnen am 19. Jun 2009 · letzter Beitrag vom 5. Okt 2009
Antwort Antwort
qwertz543221
(Gast)

n/a Beiträge
 
#1

Re: Chinesischer Restsatz, pseudocode gesucht

  Alt 5. Okt 2009, 18:26
Das ganze soll auch nicht nach dem original schema x°d mod n berechnet werden, da genau dies zu langsam ist., Deshalb erfolgt eine aufteilung.
Delphi-Quellcode:
 function tform1.rsadec2(text:ansistring;d,n:ansistring):ansistring;
var
i,j:int64;
wa,h:ansistring;

begin
result:='';
mathe:=tmathe.Create;
i:=1;

 while i<=length(text) do
  begin
  application.ProcessMessages;
wa:='';
 j:=i;
 while j<i+length(n) do
 begin
 wa:=wa+text[j];
 j:=j+1;
 end;
 cp:=mathe.Modulo(wa,p);
 cq:=mathe.Modulo(wa,q);
dp:= mathe.modulo(d, mathe.differenz(p,'1');
dq:= mathe.modulo(d, mathe.differenz(q,'1');

//hier ist doch potenzmod(), der quelle nach ist insgesamt nur zweimal potenzmod anzuwenden:

 mp:=mathe.PotenzModulo(cp,dp,p);
 mq:=mathe.PotenzModulo(cq,dq,q) ;

 wa:=mathe.Modulo(mathe.Summe(mathe.Produkt(mathe.Produkt(mp,yq),q),mathe.Produkt(mathe.Produkt(mq,yp),p)),n);
 // result:=result+numtotext(wa);
  i:=i+length(n)
  end;
   end;

procedure Tform1.DECmitChinRS1Click(Sender: TObject);
var d,n:ansistring;
function rsadec2(text:ansistring;d,n:ansistring):ansistring;
var
i,j:int64;
c,h,m:ansistring;

begin
result:='';
mathe:=tmathe.Create;
i:=1;
 while i<=length(text) do
  begin
  application.ProcessMessages;
c:='';
 j:=i;
 while j<i+length(n) do
 begin
 c:=c+text[j];
 j:=j+1;
 end;
 cp:=mathe.Modulo(c,p);
 cq:=mathe.Modulo(c,q);
 m:=mathe.modulo(mathe.Summe((mathe.produkt(mathe.produkt(mp,yq),q)),(mathe.produkt(mathe.produkt(mq,yp),p))),n) ;

 result:=result+numtocomb(strtoint(m));
 i:=i+length(n);

  end;
   end;
  begin
try
d:=(labeledEdit1.Text);
n:=(LabeledEdit2.Text);
memo2.Lines.add(datetimetostr(now)+': RSA - Starte Dechiffrierung mit chin RS.');
memo1.Text:=rsadec(memo1.Text,d,n);
memo2.Lines.add(datetimetostr(now)+': RSA - Dechiffriert mit chin RS.');
memo2.lines.add('---------------------------------------------------');
except
on e:exception do
begin
e.Message;
memo2.Lines.add(datetimetostr(now)+': RSA - Dechiffrierung fehlgeschlagen.');
memo2.lines.add('---------------------------------------------------');
end;
 end;
end;
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:33 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz