Note that there are some explanatory texts on larger screens.

plurals
  1. POdecrypting using rijndael. DCPcrypt library. Delphi
    primarykey
    data
    text
    <p>I have a IV (initialization vector) and key, also a cryptogram. I need do decrypt the cryptogram. From the internet i found <a href="http://www.cityinthesky.co.uk/cryptography.html" rel="nofollow">DCPcrypt Cryptographic Component Library v2</a>. So, now i've reached to coding.</p> <pre><code>procedure TForm1.Button1Click(Sender: TObject); var key:Ansistring; ivector,indata,outdata:string; begin key := 'abc12345679'; //&lt;--key for decrypting dcp_rijndael1.InitStr(key,TDCP_sha1); //I don't understand why i need hashing!? ivector := edit2.Text; //initialization vector dcp_rijndael1.SetIV(ivector); dcp_rijndael1.BlockSize := Length(ivector); //'This variable should be the same size as the block size' says the documentation indata := edit1.Text; //getting the cryptogram dcp_rijndael1.CipherMode := cmCBC; dcp_rijndael1.DecryptCBC(indata,outdata,Length(indata)); label3.Caption := outdata; //output to label end; </code></pre> <p>This code gives me an error. "Local Variables" window shows indata, outdata, ivector, key variables as 'Inaccessible value'. Or maybe is there another way to do it. This seems pretty straight forward, though. Thanks in advance.</p> <p><strong>After Wodzu help:</strong> Notice, that i receive decrypted string encoded with base64, so i guess, i need to decode it first.</p> <pre><code>var Form1: TForm1; StringToEncrypt, StringToDecrypt, DecryptedString: string; vector:string; procedure TForm1.Button2Click(Sender: TObject); begin vector := '1234567812345678'; //Length 16 stringtodecrypt := '2YOXZ20Z7B3TRI/Ut8iH/GpEZWboE2tnnWU'; stringtodecrypt := Decode64(stringtodecrypt); //after encrypted string is sent over internet, it is encoded with base64, so i need to decode it. SetLength(DecryptedString, 36); //36 is the length of the output DCP_rijndael1.Init('MyKey:128bit', 128, @Vector[1]); DCP_rijndael1.SetIV(Vector); DCP_rijndael1.BlockSize := Length(Vector); //Should this be also 128 DCP_rijndael1.DecryptCBC(StringToDecrypt[1], DecryptedString[1], Length(StringToDecrypt)*2); //Here i get hieroglyph as a result. Why is length multiplied with 2? decryptedstring := Encode64(decryptedstring); //Here i get less hieroglyph, but would like to get correct decrypted string. I doubt the necessity of encoding ShowMessage(DecryptedString); end; </code></pre> <p>I can't make this code to decrypt data that somebody else is encrypting (with PHP) (after encrypting the data is encoded with base64). <strong>Note!</strong> encrypted text length is not the same as the decrypted text length!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload