Delphi XE8 Support MD5(2015-08-14 15:18)
reproduced
Tags: MD5 |
Category: DelphiXE8 |
XE8 A new unit file: System.hash, in fact, implemented three classes, respectively:
Thash
THashMD5
THashSHA1
Native implementation of the MD5 and SHA1 support!
Taking MD5 as an example, it is easy to take a string of MD5 values.
Procedure Tform40.button2click (Sender:tobject);
Var
MD5:THASHMD5;
Begin
Label1.text:=md5. Gethashstring (edit1. Text);//Generate 32-character-length MD5
You can also do this:
Md5:=thashmd5.create;
MD5. Update (edit1. Text);
Label1.text:=md5. hashasstring;
End
THashMD5 is a record type, so there is no need to release an established instance.
The THASHMD5 also provides HMAC support:
Label1.text:=md5. Gethmac (Edit1.text, ' Red Fish ');//Generate a 32-character-length HMAC.
This can not be said is XE8 progress, complex MD5 and other algorithms, for the Delphi developers are also directly used, simple, convenient!
PostScript: XE9 added SHA2 support!
Report:
Hash algorithm and its application
---------------
What is a Hash?
Hash Reading (135) ┆ Comments (0) ┆ reprint (1) ┆ collection (0)View full text >>Delphi Classic Uppercase Number conversion function(2015-08-09 21:17)
reproduced
Tags: delphi It |
Category: DelphiXE8 |
Convert the number to uppercase function, from here, the original text in the Delphi XE8 under the normal conversion.
Function Moneyconvert (mmje:real): string;
Const
S1:string = ' 0 One and three Woolu qi Ba Jiu ';
s2:string = ' Corner of the yuan to pick up bai thousand hundred thousand million to pick up hundred thousand million ';
Function Strtran (const S, S1, s2:string): string;
Begin
Result: = S.replace (S1, S2, [Rfreplaceall]);
End
Var
S, dx:string;
I, Len:integer;
Begin
If Mmje < 0 Then
Begin
DX: = ' negative ';
Mmje: =-mmje;
End
S: = Format ('%.0f ', [mmje * 100]);
Len: = s.length;
For I: = 0 to Len-1 do
DX: = dx + S1. Substring (Ord (s.chars[i))-Ord (' 0 '), 1) +s2.substring (len-i-1,1);
DX: = Strtra Read (119) ┆ Comments (0) ┆ reprint (0) ┆ collection (0)View full text >>Use String type in Delphi record(2015-08-07 14:09)
reproduced
In a custom record type, using string, careless will cause a memory leak, and with the following notation, it will not be tested under Xe8.
Type
Pmyrecord=^tmyrecord;
Tmyrecord=record
I:integer;
s:string;
End
Var
P:pmyrecord;
Begin
P:=new (Pmyrecord);//Allocating memory
p.i:=100;//Here I abbreviated, can also be written p^.i
p.s:= ' aaaaaa ';
Dispose (P);//release memory, here is the focus, p is already the Pmyrecord type, so do not convert,
if it is an untyped pointer, type conversions are done, such as Dispose (Pmyrecord (p));
End
Delphi MD5 algorithm