Привет всем!
Была необходимость поставить сап систему. Но при установке инсталятор попросил ключик, который генериться в СМ. Пришлось поэтому поводу ставить СМ, генерить ключик и потом сносить эту систему.
Из СМ я выдрал код по генерации ключиков и написал абап программу, которая их генерит. Так что если кому-нибудь не охота будет ставить для этих целей СМ, то может воспользоваться данной программой
Code:
*&---------------------------------------------------------------------*
*& Report ZBC_SOLMAN_KEY
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
report zbc_solman_key.
selection-screen begin of block sele1 with frame.
parameters:
sid(3),
sysno(2),
server(15).
selection-screen end of block sele1.
selection-screen begin of block sele2 with frame.
parameters:
key(10).
selection-screen end of block sele2.
at selection-screen.
if sid is not initial and
sysno is not initial and
server is not initial.
perform get_sp_value using sid sysno server changing key.
else.
clear key.
endif.
*&---------------------------------------------------------------------*
*& Form get_sp_value
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_PF_SID text
* -->P_PF_SYSNO text
* -->P_PF_SERVER text
* <--P_PF_VALUE text
*----------------------------------------------------------------------*
form get_sp_value using p_pf_sid
p_pf_sysno
p_pf_server
changing p_pf_value.
constants:
lc_part_len type i value 5,
lc_pw_len type i value 10,
lc_allowed_chars(38) type c value '-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_'.
data: lf_string(20) type c,
lf_key type i,
lf_part(lc_part_len) type c,
lf_finalf(lc_pw_len) type c,
lf_finalx type xstring,
lf_xbuffer type xstring,
lf_opf(10) type c,
lf_langu like sy-langu,
lf_subrc like sy-subrc,
lf_len type i,
lo_conv_to_x type ref to cl_abap_conv_out_ce.
clear: lf_string, lf_finalx, lf_opf.
concatenate p_pf_sid p_pf_sysno p_pf_server into lf_string.
* Large letters only
translate lf_string to upper case.
lf_langu = sy-langu.
set locale language 'E'.
lo_conv_to_x = cl_abap_conv_out_ce=>create( encoding = '1100' ).
lf_len = strlen( lf_string ).
if lf_string(lf_len) cn lc_allowed_chars.
else.
* Fold the input string to a lc_part_len long string
while lf_len > 0.
lf_part = lf_string(lc_part_len).
shift lf_string by lc_part_len places.
lf_len = strlen( lf_string ).
call method lo_conv_to_x->reset.
call method lo_conv_to_x->write( data = lf_part n = -1 ).
lf_xbuffer = lo_conv_to_x->get_buffer( ).
lf_finalx = lf_finalx bit-xor lf_xbuffer.
endwhile.
lf_key = 12.
perform scramble using lf_finalx
lf_key
lc_part_len
changing lf_finalf
lf_subrc.
if not lf_finalf is initial.
p_pf_value = lf_finalf.
else.
clear p_pf_value.
endif.
endif.
endform. " get_sp_value
*&---------------------------------------------------------------------*
*& Form scramble
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LF_FINALX text
* -->P_LF_KEY text
* -->P_LC_PART_LEN text
* <--P_LF_finalf text
* <--P_LF_SUBRC text
*----------------------------------------------------------------------*
form scramble using iv_xstring type xstring
iv_key type i
iv_src_len type i
changing lf_finalf
lf_subrc like sy-subrc.
constants: lc_max_len type i value 20,
lc_mask(4) type x value '0000003F',
lc_random(64) type x value
'F0ED53B83244F1F876C67959FD4F13A2' &
'C15195EC5483C234774943A27DE26596' &
'5E5398789A17A33CD383A8B829FBDCA5' &
'55D702778413ACDDF9B83116610E6DFA'.
data: lv_key_index(4) type x,
lv_rand_index(4) type x,
lv_xkey(4) type x,
lv_xkey_shl_1(4) type x,
lv_xkey_shr_5(4) type x,
lv_scramble_byte type x,
lv_dest(lc_max_len) type x,
lv_index type i,
lv_len type i.
clear lf_subrc.
if iv_src_len eq 0. exit. endif.
lv_len = xstrlen( iv_xstring ).
if iv_src_len gt lc_max_len or
iv_src_len gt lv_len.
lf_subrc = 2.
exit.
endif.
lv_xkey = iv_key.
lv_xkey_shl_1 = iv_key * 2.
lv_xkey_shr_5 = iv_key div 32.
lv_rand_index = lv_xkey bit-xor lv_xkey_shr_5 bit-xor lv_xkey_shl_1.
lv_rand_index = lv_rand_index bit-and lc_mask.
lv_index = 0.
do iv_src_len times.
catch system-exceptions compute_int_times_overflow = 1.
lv_key_index = ( iv_key * lv_index * lv_index ) - lv_index.
endcatch.
if sy-subrc <> 0.
lf_subrc = 1.
exit.
endif.
lv_scramble_byte = lc_random+lv_rand_index(1) bit-xor
lv_key_index+3(1).
lv_dest+lv_index(1) = iv_xstring+lv_index(1) bit-xor
lv_scramble_byte.
lv_index = lv_index + 1.
lv_rand_index = lv_rand_index + 1.
lv_rand_index = lv_rand_index bit-and lc_mask.
enddo.
if lf_subrc <> 0.
exit.
endif.
write lv_dest(iv_src_len) to lf_finalf.
endform. " scramble