C写的加密算法,请高手帮忙翻译成java的
int usrcrypt(char *usrid, char *usrpasswd, char *usrpasswd_out)
{
//add by chenzm 
char usrid_in    [128]="\0";
char usrpasswd_in[128]="\0";
memset(usrid_in    ,0,128);
memset(usrpasswd_in,0,128);
strncpy(usrid_in,usrid + (strlen(usrid) - 9),9);
//strcpy(usrid_in    ,usrid    );
strcpy(usrpasswd_in,usrpasswd);
//add end 

int bytes = 6;
int retlen = 6;
int l, a, j, k, i, m; int rand_seed1 = 23456;
int rand_seed2 = 31212;
int rand_seed3 = 1029;
int mod_seed = 32768; char pwd[256+1] = "\0";
int mm[100+1];
char cmm[256+1] = "\0";
char l_str[256+1] = "\0";
char t_str[2] = "\0";
    
    if (strlen(usrpasswd_in) != 6)
return -1; strcat(usrpasswd_in, usrid_in);
strcpy(pwd, usrpasswd_in);
l = strlen(pwd);
for (j = 1; j <= l; j++)
{
a = (int)pwd[j-1];
rand_seed1 = (rand_seed1 + a*j) % mod_seed;
rand_seed2 = ((rand_seed2 + a*(l-j)) % (mod_seed/4)) * 2;
rand_seed3 = ((rand_seed3 + a*a) % (mod_seed/4))*2 + 1;
}
if (bytes > 10) 
bytes = 10;
l = strlen(usrpasswd_in);
    if (l > bytes)
{
        strncpy(l_str, usrpasswd_in, bytes);
        strcpy(usrpasswd_in, l_str);
}
else
{
i = l;
for (l = i+1; l <= bytes; l++)
{
rand_seed1 = (rand_seed1*rand_seed2 + rand_seed3) % mod_seed;
a = rand_seed1 % 126;
if (a < 33)
{
a = 'A' + a;
}
t_str[0] = a;
strcat(usrpasswd_in, t_str);
}
}
l = strlen(usrid_in);
if (l > bytes)
{
        strncpy(l_str, usrid_in, bytes);
        strcpy(usrid_in, l_str);
}
else
{
i = l;
for (l = i+1; l <=bytes; l++)
{
rand_seed1 = (rand_seed1*rand_seed2 + rand_seed3) % mod_seed;
a = rand_seed1 % 126;
if (a < 33)
{
a = 'A' + a;
}
t_str[0] = a;
strcat(usrid_in, t_str);
}
}
for (l = 1; l <= 100; l++)
{
mm[l-1] = 0;
}
a = (rand_seed1*rand_seed2 + rand_seed3) % mod_seed;
for (l = 1; l <= bytes; l++)
{
for (k = 1; k <= bytes; k++)
{
a = (a*rand_seed1 + (int)usrpasswd_in[l-1]*(int)usrid_in[l-1]*l) % mod_seed;//a := mod( a*rand_seed1+ASCII(SUBSTRB(iv_usrpasswd, l, 1))*ASCII(SUBSTRB(iv_usrid , l,1))*l,mod_seed );
            if (a >= (mod_seed/2))
{
rand_seed1 = (rand_seed1*rand_seed2 + rand_seed3) % mod_seed;
      mm[rand_seed1 % (bytes*bytes)] = rand_seed1;
}
else
{
rand_seed1 = (rand_seed1*(rand_seed3+1) + rand_seed2 + 1) % mod_seed;
      mm[rand_seed1 % (bytes*bytes)] = rand_seed1;
}
}
}
for (k = 1; k <= bytes*bytes; k++)
{
if (k > 1)
{
m = mm[k]/256;
mm[k-1] = mm[k-1] + m;
}

}
for (l = 1; l <= bytes*bytes; l++)
{
rand_seed1 = (rand_seed1*rand_seed1) % mod_seed;
if (mm[l] == 0)
mm[l] = rand_seed1;
} for ( k = 1; k <= bytes; k++)
{
for (l = 1; l <= bytes; l++)
{
a = (mm[l+(k-1)*bytes]*usrid_in[k-1]*usrpasswd_in[l-1]) % 62;//a:=mod(mm(l+(k - 1)*bytes)*ASCII(SUBSTRB(iv_usrid,k,1))*ASCII(SUBSTRB(iv_usrpasswd,l,1)),62);
            if (a < 10)
{
t_str[0] = a + '0';
strcat(cmm, t_str);
}
else if(a < 36)
{
t_str[0] = a - 10 + 'a';
strcat(cmm, t_str);
}
else if(a < 62)
{
t_str[0] = a - 36 + 'A';
strcat(cmm, t_str);
}
else
{
strcat(cmm, "_");
}
}
}
strncpy(l_str, cmm, retlen);
    strcpy(cmm, l_str);
    strcpy(usrpasswd_out, cmm);
    if (strlen(usrpasswd_out) != 6)
        return -1;    //cuserlog("用户或客户id[%s],用户或客户密码(明码)[%s],加密后的密码[%s]",usrid,usrpasswd,usrpasswd_out);    
    return 0;
}