Function KeyGen(as_code: String): String;
Var
ls_base: String;
li_key, li_len, li_loop, li_strlen, li_tmp, li_right_mod: integer;
Begin
ls_base := '3ffsrVWU723slBC76348QT5678dJKy08012314r676343462236DRmjnr9qasSE012';
li_len := 50;
If Length(as_code) < 50 Then li_len := Length(as_code);
For li_loop := 1 To li_len Do
Begin
li_key := li_key + Ord(as_code[li_loop]);
If (li_loop Mod 2) = 1 Then li_key := li_key + Ord(as_code[li_loop]);
End;
li_key := li_key + 50;
li_strlen := 25;
For li_loop := 1 To li_strlen Do
Begin
li_len := Length(ls_base);
li_tmp := li_key Mod li_len;
li_tmp := li_tmp + li_right_mod;
If li_tmp > li_len Then li_tmp := li_tmp Mod li_len;
If li_tmp = 0 Then li_tmp := 1;
Result := Result + ls_base[li_tmp];
li_right_mod := li_tmp;
ls_base := LeftStr(ls_base, li_tmp - 1) + RightStr(ls_base, li_len - li_tmp);
End;
Result := StringReplace(UpperCase(Result), 'O', '0', [rfReplaceAll]);