Recent

Author Topic: Encryption and decryption  (Read 18321 times)

EvelRus

  • Newbie
  • Posts: 1
Encryption and decryption
« on: January 25, 2013, 11:41:43 am »
Good day!
Please tell me whether the Lazarus module to encrypt and decrypt text, say the password?
Looking toward DCPcrypt, but could not find the version for Lazarus to the site developer.
Interested module with the ability to decrypt
Thanks in advance!

Deepaak

  • Sr. Member
  • ****
  • Posts: 445
Re: Encryption and decryption
« Reply #1 on: January 25, 2013, 12:41:28 pm »
DCPcrypt components for Lazarus.

http://wiki.freepascal.org/DCPcrypt
Holiday season is online now. :-)

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Encryption and decryption
« Reply #2 on: January 25, 2013, 05:07:32 pm »
If you just need a simple Encryption / Decription
This is a fast and powerful Encryption

http://www.freepascal.org/docs-html/fcl/blowfish/tblowfish.html

And it does not require installing anything further, compiling etc

Just add BlowFish to your uses :)

If you just need simple encoding you can use the following method
for example you just want to keep your brother or sister, gf etc
from reading your list of porn sites, you could encode them
though this method would stop a normal user from decyphering your
contents It will not stop a anyone whom is familar with base64 encoding


and if your dealing with web servers etc user names and passwords are encoded
using base64  and you could add that to your uses.

A sample output of wjackson153:password

label1.caption := EncodeStringBase64('wjackson153:password');
output would look like d2phY2tzb24xNTM6cGFzc3dvcmQ=

label1.caption :=DecodeStringBase64('d2phY2tzb24xNTM6cGFzc3dvcmQ=');
« Last Edit: January 25, 2013, 05:36:53 pm by wjackson153 »
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Encryption and decryption
« Reply #3 on: January 25, 2013, 06:15:26 pm »
Blowfish doesn't seem that simple, i can't find those functions. I'm guessing you have to initialize the encryption with a key first, and then use TBlowFishEncryptStream and TBlowFishDeCryptStream.

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Encryption and decryption
« Reply #4 on: January 25, 2013, 06:50:08 pm »
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

User137

  • Hero Member
  • *****
  • Posts: 1791
    • Nxpascal home
Re: Encryption and decryption
« Reply #5 on: January 25, 2013, 08:13:59 pm »
Why link wiki twice  >:(

You may be referring to marcov's post at:
http://www.lazarus.freepascal.org/index.php/topic,11813.msg59617.html#msg59617
Those are not included in the fpc. And they are not using blowfish or any other encryption. Just Base64 conversion.
« Last Edit: January 25, 2013, 08:16:45 pm by User137 »

wjackson153

  • Sr. Member
  • ****
  • Posts: 267
Re: Encryption and decryption
« Reply #6 on: January 25, 2013, 08:57:52 pm »
Yes sorry I posted wrong link 2nd time  O:-)
Lazarus 1.1 r39490 CT FPC 2.7.1 i386-linux KDE
Linux Mint 14 KDE 4

Deepaak

  • Sr. Member
  • ****
  • Posts: 445
Re: Encryption and decryption
« Reply #7 on: January 26, 2013, 04:19:47 am »
Freepascal Blowfish simple example

Code: [Select]
{$mode objfpc}{$H+}

uses classes,blowfish,windows;

var
  en: TBlowFishEncryptStream;
  de: TBlowFishDeCryptStream;
  s1,s2: TStringStream;
  key,value,temp: String;
begin
  key := 'testkey';
  value := 'this is a string';

  s1 := TStringStream.Create('');
  en := TBlowFishEncryptStream.Create(key,s1);
    en.Write(value[1],Length(value));
  en.Free;


  MessageBox(0,PChar(s1.DataString),'',MB_OK);
  s2 := TStringStream.Create(s1.DataString);
  s1.Free;

  de := TBlowFishDeCryptStream.Create(key,s2);

  SetLength(temp,s2.Size);
  de.Read(temp[1],s2.Size);

  MessageBox(0,PChar(temp),'',MB_OK);
  de.Free;

  s2.Free;
end.

Hope this may help you.  :D
Holiday season is online now. :-)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8294
  • Programming + Glam Metal + Tae Kwon Do = Me

 

TinyPortal © 2005-2018