Autor |
Beitrag |
Laxans
      
Beiträge: 28
|
Verfasst: Do 27.11.03 22:52
Ich möchte eine Datei verschlüsseln... ich habe in diesem forum gescuht und letztendlich www.scramdisk.clara..../delphi/dcpcrypt.zip gefunden. Die Frage die sich mir stellt: Wie benutzt man das.
Kann mir das jemand verklickern??? (Am Liebsten Blowfish)
Thx
|
|
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1
|
Verfasst: Fr 28.11.03 05:50
Hast du dir das Archiv schon mal näher angekuckt?  Rat mal, was man darin findet. 
|
|
Laxans 
      
Beiträge: 28
|
Verfasst: Fr 28.11.03 17:32
Klugsch******...
ich die datei usage.txt gefunden und gelesen, aber ich blick da nicht durch. kann mir das mal jemand verklickern?
|
|
obbschtkuche
Gast
Erhaltene Danke: 1
|
Verfasst: Fr 28.11.03 17:39
Ähmm.... da ist ein Ordner Demo, aber den hast du dir ja bestimmt schon angeguckt, also sag am Besten mal, was du nicht verstehst.
|
|
Laxans 
      
Beiträge: 28
|
Verfasst: Fr 28.11.03 17:43
ich weiß nicht wie ich mir was kopieren muss um das in meinem Prog zu benutzen. Außerdem will ich es nicht nur anwenden sondern auch verstehen.
|
|
Laxans 
      
Beiträge: 28
|
Verfasst: Fr 28.11.03 17:57
ich kann dir das ding so wie ich denke dass das sein müsste per e-mail schicken und du sagst mir dann was falsch ist ok?
|
|
obbschtkuche
Gast
Erhaltene Danke: 1
|
Verfasst: Fr 28.11.03 19:40
Nein, aber du kannst es hier posten, damit andere Leute mal was davon haben werden.
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Mi 17.12.03 10:08
Titel: Doc Verzeichnis
Im Verzeichnis doc gib es ein paar anleitungen in dein fall wär "cipher" das richtige. Da findet man die nötige functionen zu ver, und entschlüsselung von Strings und Filestreams. Wenn du es nicht findest sag bescheid und ich mails dir.
Jeremy
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Mi 17.12.03 10:15
Titel: oder noch besser
oder noch besser ich post der html doc mal einfach hier
Zitat: |
DCPcrypt Cryptographic Component Library v2
Copyright © 1999-2002 David Barton
www.cityinthesky.co.uk/
crypto@cityinthesky.co.uk
Ciphers - TDCP_cipher
All ciphers are inherited from the TDCP_cipher component either directly for stream ciphers (such as RC4) or via the TDCP_blockcipher component.
The TDCP_cipher component implements key initialisation features and the basic encryption/decryption interface. Functions available are:
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17:
| property Initialized: boolean; property Id: integer; property Algorithm: string; property MaxKeySize: integer; class function SelfTest: boolean; procedure Init(const Key; Size: longword; InitVector: pointer); procedure InitStr(const Key: string; HashType: TDCP_hashclass); procedure Burn; procedure Reset; procedure Encrypt(const Indata; var Outdata; Size: longword); procedure Decrypt(const Indata; var Outdata; Size: longword); function EncryptStream(InStream, OutStream: TStream; Size: longword): longword; function DecryptStream(InStream, OutStream: TStream; Size: longword): longword; function EncryptString(const Str: string): string; function DecryptString(const Str: string): string; |
Example usage:
Example 1 - String encryption.
Example 2 - File encryption.
Example 3 - General encryption.
--------------------------------------------------------------------------------
Function descriptions
Delphi-Quelltext 1:
| property Initialized: boolean; |
Once key initialization has been performed this property is set to true, otherwise it is set to false. Calling Burn will immediately set this to false.
Delphi-Quelltext
Every algorithm I implement gets given a unique ID number so that if I use several different algorithms within a program I can determine which one was used. This is a purely arbitrary numbering system.
Delphi-Quelltext 1:
| property Algorithm: string; |
This contains the name of the algorithm implemented within the component.
Delphi-Quelltext 1:
| property MaxKeySize: integer; |
This is the maximum size of key you can pass to the cipher (in bits!).
Delphi-Quelltext 1:
| class function SelfTest: boolean; |
In order to test whether the implementations have all been compiled correctly you can call the SelfTest function. This compares the results of several encryption/decryption operations with known results for the algorithms (so called test vectors). If all the tests are passed then true is returned. If ANY of the tests are failed then false is returned. You may want to run this function for all the components when you first install the DCPcrypt package and again if you modify any of the source files, you don't need to run this everytime your program is run. Note: this only performs a selection of tests, it is not exhaustive.
Delphi-Quelltext 1:
| procedure Init(const Key; Size: longword; InitVector: pointer); |
This procedure initializes the cipher with the keying material supplied in Key. The Size of the keying material is specified in BITS. The InitVector is a pointer to chaining information (only used for block ciphers). The variable that this points to should be equal to the block size of the algorithm. If nil is specified then (if necessary) an initialization vector is automatically generated from the key. Note: the method for generating automatic IVs is different from DCPcrypt v1.31, if this is a problem uncomment the DCPcrypt v1.31 compatibility mode line in DCPcrypt2.pas.
Init example: use the hash of a string to initialize the cipher
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| procedure TForm1.Button1Click(Sender: TObject); var Cipher: TDCP_rc4; Hash: TDCP_sha1; Digest: array[0..19] of byte; begin Hash:= TDCP_sha1.Create(Self); Hash.Init; Hash.UpdateStr(Edit1.Text); Hash.Final(Digest); Hash.Free; Cipher:= TDCP_rc4.Create(Self); Cipher.Init(Digest,Sizeof(Digest)*8,nil); ... procedure InitStr(const Key: string; HashType: TDCP_hashclass); |
This procedure initializes the cipher with a hash of the key string using the specified hash type (in a way similar to the example above). To replicate the behaviour from DCPcrypt v2 Beta 1 use Cipher.InitStr(KeyStr,TDCP_sha1).
InitStr example: prompt the user for a passphrase to initialize the cipher
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9:
| procedure TForm1.Button1Click(Sender: TObject); var Cipher: TDCP_rc4; begin Cipher:= TDCP_rc4.Create(Self); Cipher.InitStr(InputBox('Passphrase','Enter a passphrase',''),TDCP_sha1); ... procedure Burn; |
Once you have finished encrypting/decrypting all your data call Burn to erase all keying information. This is automatically called once the cipher is freed, however it is a good habit to call this procedure explicitly.
Delphi-Quelltext
Stream ciphers (and block ciphers in chaining modes) generally store chaining information that is dependant on the information already encrypted. Consequently decrypting a block of information immediately after encrypting it won't result in the original information because when you called the decrypt procedure the chaining information was different from when you called the encrypt procedure. Hence use Reset to restore the chaining information to it's original state.
Remember that calling EncryptString, DecryptString, EncryptStream and DecryptStream will also affect the chaining information.
Reset example: encrypting and decrypting
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
| function TestCipher: boolean; const InData: array[0..9] of byte= ($01,$23,$45,$56,$67,$78,$89,$10,$AB,$FF); var Cipher: TDCP_rc4; Data: array[0..9] of byte; begin Cipher:= TDCP_rc4.Create(nil); Cipher.InitStr('Hello World',TDCP_sha1); Cipher.Encrypt(InData,Data,Sizeof(Data)); Cipher.Decrypt(Data,Data,Sizeof(Data)); Cipher.Burn; Cipher.Free; Result:= CompareMem(@InData,@Data,Sizeof(Data)); end; |
The above will ALWAYS result in false due to the chaining information.
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16:
| function TestCipher: boolean; const InData: array[0..9] of byte= ($01,$23,$45,$56,$67,$78,$89,$10,$AB,$FF); var Cipher: TDCP_rc4; Data: array[0..9] of byte; begin Cipher:= TDCP_rc4.Create(nil); Cipher.InitStr('Hello World',TDCP_sha1); Cipher.Encrypt(InData,Data,Sizeof(Data)); Cipher.Reset; Cipher.Decrypt(Data,Data,Sizeof(Data)); Cipher.Burn; Cipher.Free; Result:= CompareMem(@InData,@Data,Sizeof(Data)); end; |
The above should always return true.
Delphi-Quelltext 1:
| procedure Encrypt(const Indata; var Outdata; Size: longword); |
Encrypt Size bytes from Indata and place it in Outdata. Block ciphers encrypt the data using the method specified by the CipherMode property. Also see the notes on Reset.
Delphi-Quelltext 1:
| procedure Decrypt(const Indata; var Outdata; Size: longword); |
Decrypt Size bytes from Indata and place it in Outdata. Block ciphers decrypt the data using the method specified by the CipherMode property. Also see the notes on Reset.
Delphi-Quelltext 1:
| function EncryptStream(InStream, OutStream: TStream; Size: longword): longword; |
Encrypt Size bytes from the InStream and place it in the OutStream, returns the number of bytes read from the InStream. Encryption is done by calling the Encrypt procedure. Also see the notes on Reset.
Delphi-Quelltext 1:
| function DecryptStream(InStream, OutStream: TStream; Size: longword): longword; |
Decrypt Size bytes from the InStream and place it in the OutStream, returns the number of bytes read from the InStream. Decryption is done by calling the Decrypt procedure. Also see the notes on Reset.
Delphi-Quelltext 1:
| function EncryptString(const Str: string): string; |
Encrypt the string Str then Base64 encode it and return the result. For stream ciphers the Encrypt procedure is called to do the encryption, for block ciphers the CFB8bit method is always used. Base64 encoding is used to ensure that the output string doesn't contain non-printing characters.
Delphi-Quelltext 1:
| function DecryptString(const Str: string): string; |
Base64 decode the string then decrypt it and return the result. For stream ciphers the Decrypt procedure is called to do the decryption, for block ciphers the CFB8bit method is always used.
--------------------------------------------------------------------------------
Example 1: String encryption
This example shows how you can encrypt the contents of a TMemo and leave the contents printable.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35:
| procedure TForm1.btnEncryptClick(Sender: TObject); var i: integer; Cipher: TDCP_rc4; KeyStr: string; begin KeyStr:= ''; if InputQuery('Passphrase','Enter passphrase',KeyStr) then begin Cipher:= TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr,TDCP_sha1); for i:= 0 to Memo1.Lines.Count-1 do Memo1.Lines[i]:= Cipher.EncryptString(Memo1.Lines[i]); Cipher.Burn; Cipher.Free; end; end; procedure TForm1.btnDecryptClick(Sender: TObject); var i: integer; Cipher: TDCP_rc4; KeyStr: string; begin KeyStr:= ''; if InputQuery('Passphrase','Enter passphrase',KeyStr) then begin Cipher:= TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr,TDCP_sha1); for i:= 0 to Memo1.Lines.Count-1 do Memo1.Lines[i]:= Cipher.DecryptString(Memo1.Lines[i]); Cipher.Burn; Cipher.Free; end; end; |
--------------------------------------------------------------------------------
Example 2: File encryption
This example shows how you can encrypt the contents of a file, takes the input and output file names from two edit boxes: boxInputFile and boxOutputFile.
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51:
| procedure TForm1.btnEncryptClick(Sender: TObject); var Cipher: TDCP_rc4; KeyStr: string; Source, Dest: TFileStream; begin KeyStr:= ''; if InputQuery('Passphrase','Enter passphrase',KeyStr) then begin try Source:= TFileStream.Create(boxInputFile.Text,fmOpenRead); Dest:= TFileStream.Create(boxOutputFile.Text,fmCreate); Cipher:= TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr,TDCP_sha1); Cipher.EncryptStream(Source,Dest,Source.Size); Cipher.Burn; Cipher.Free; Dest.Free; Source.Free; MessageDlg('File encrypted',mtInformation,[mbOK],0); except MessageDlg('File IO error',mtError,[mbOK],0); end; end; end; procedure TForm1.btnDecryptClick(Sender: TObject); var Cipher: TDCP_rc4; KeyStr: string; Source, Dest: TFileStream; begin KeyStr:= ''; if InputQuery('Passphrase','Enter passphrase',KeyStr) then begin try Source:= TFileStream.Create(boxInputFile.Text,fmOpenRead); Dest:= TFileStream.Create(boxOutputFile.Text,fmCreate); Cipher:= TDCP_rc4.Create(Self); Cipher.InitStr(KeyStr,TDCP_sha1); Cipher.DecryptStream(Source,Dest,Source.Size); Cipher.Burn; Cipher.Free; Dest.Free; Source.Free; MessageDlg('File decrypted',mtInformation,[mbOK],0); except MessageDlg('File IO error',mtError,[mbOK],0); end; end; end; |
--------------------------------------------------------------------------------
Example 3: General encryption
This hypothetical example shows how you might encrypt a packet of information before transmission across a network.
Delphi-Quelltext 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30:
| type TSomePacket= record Date: double; ToUserID: integer; FromUserID: integer; MsgLen: integer; Msg: string; end; procedure EncryptPacket(Cipher: TDCP_cipher; var Packet: TSomePacket); begin if Cipher= nil then raise Exception.Create('Cipher hasn''t been created!') else begin if not Cipher.Initialized then Cipher.InitStr(InputBox('Passphrase','Enter passphrase',''),TDCP_sha1); if Cipher is TDCP_blockcipher then TDCP_blockcipher(Cipher).CipherMode:= cmCFB8bit; Cipher.Encrypt(Packet.Date,Packet.Date,Sizeof(Packet.Date)); Cipher.Encrypt(Packet.ToUserID,Packet.ToUserID,Sizeof(Packet.ToUserID)); Cipher.Encrypt(Packet.FromUserID,Packet.FromUserID,Sizeof(Packet.FromUserID)); Cipher.Encrypt(Packet.MsgLen,Packet.MsgLen,Sizeof(Packet.MsgLen)); Cipher.Encrypt(Packet.Msg[1],Packet.Msg[1],Length(Packet.Msg)); end; end; |
Index, Block Ciphers, Hashes
DCPcrypt is copyrighted © 1999-2002 David Barton.
All trademarks are property of their respective owners.
|
Hoff das hilt weiter
Moderiert von Motzi: Delphi-Tags in Zitat eingefügt.
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
BungeeBug
      
Beiträge: 901
|
Verfasst: Mi 17.12.03 15:40
Sicher könnte das helfen nur will warscheinlich keiner das alles lesen nur um dir die Arbeit abzunehmen ... mein Vorschlag (auch auf die Gefahr hin das du mich ähnlich wie Luckie gleich anpi*st )
1) Lehrn nen bissel was über Benehemen in Foren das Wort das du im Duden suchen musst heisst "Höflichkeit".
2) Nimmst du dir jetzt nen Englisch Deutsch - Deutsch Englisch Wörterbuch und übersetzt das ganze mal ...
viel Spass 
|
|
Christian S.
      
Beiträge: 20451
Erhaltene Danke: 2264
Win 10
C# (VS 2019)
|
Verfasst: Mi 17.12.03 15:44
Hallo, BungeeBug!
Du weißt, dass Du gerade jemanden angemotzt hat, der nur eine Antwort und keine Frage gepostet hat?
MfG
Peter
_________________ Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Mi 17.12.03 16:53
Titel: Danke
Danke @Peter Lustig. Das war eindirekte zitat aus der Dokumentation, worüber der frage war. Aus dem grund das die doku nicht gefunden werden könnte ich habs nur gepostet. Auf wünsch kann ichs auch mailen, ich hab nur gedacht das den posten hilft vielleicht mehr als nur eine mit dem gleichen problem.
Jeremy
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
Christian S.
      
Beiträge: 20451
Erhaltene Danke: 2264
Win 10
C# (VS 2019)
|
Verfasst: Mi 17.12.03 17:01
Hallo!
Das posten ist meiner Meinung nach auch besser. Ist zwar ziemlich groß, aber jemand, der das gleiche Problem hat, wird sich drüber freuen, wenn er hier die Antwort findet.
MfG
Peter
_________________ Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Mi 17.12.03 17:05
Hab ich mir auch gedacht. Und da ich nicht genau weiß WAS er verschlüsseln will hab ich halt den ganzen Cipher doch gepostet.
Jeremy
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Mi 17.12.03 17:07
opps habs besser lesen sollen  eine datei also naja ist auch drin
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
BungeeBug
      
Beiträge: 901
|
Verfasst: Mi 17.12.03 23:04
Hi,
ich hatte nich vor jmd. anzumotzen nur wenn jmd. ne Doku hat und die anscheinend nicht gelsen hat und einfach mal so fragt, die Doku gleich mitpostet frag ich mich ob ich was verpasst hab. Ausserdem waren die ersten Beiträge von ihm nicht grade freundlich. Sollte ich also jmd. beleidigt oder übel angefahren haben möchte ich mich hier mit in alle Form entschuldigen.
|
|
Christian S.
      
Beiträge: 20451
Erhaltene Danke: 2264
Win 10
C# (VS 2019)
|
Verfasst: Do 18.12.03 00:10
Zitat: | ich hatte nich vor jmd. anzumotzen nur wenn jmd. ne Doku hat und die anscheinend nicht gelsen hat und einfach mal so fragt, die Doku gleich mitpostet frag ich mich ob ich was verpasst hab. |
Hat er doch nicht! In Delphi-Code
Delphi-Quelltext
_________________ Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Do 18.12.03 08:29
Titel: angenommen
Ist schon ok Bungee. Du hast nur scheinbar was nicht verstanden. ICH hab die frage nicht gestellt. Ich hab nur versucht zu helfen ein lösung zu finden.
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
BungeeBug
      
Beiträge: 901
|
Verfasst: Do 18.12.03 18:03
Ach du heilige Sch**ße .... das tut mir nu wirklich leid ... das kommt dabei raus wenn man aufm Ast pennt. Sorry noch mal. *peinlich*
|
|
Jeremy
      
Beiträge: 99
Fedora Core 1
K3 Ent
|
Verfasst: Do 18.12.03 18:06
Braucht dir nicht peinlich zu sein. Jeder kann mal ne fehler machen. Ich kann meine fehlern in der letzte 10 min. nicht an beide hände zählen.
Jeremy
_________________ Jede ende hat ne anfang genau wie umgekehrt und windows ist der teurste mull den man kaufen kann!!!
|
|
|