hello everyone
i am working with rsa in php and b4a
php is ok. but i don't know how to convert below php codes to b4a
my code in b4a is
at last txt is empty
thanks...
i am working with rsa in php and b4a
php is ok. but i don't know how to convert below php codes to b4a
rsa decrypt:
public function decrypt ($c, $d, $n) {
$coded = explode('.', $c);
$message = '';
$max = count($coded);
for($i=0; $i<$max; $i++){
$code = bcpowmod($coded[$i], $d, $n);
while(bccomp($code, '0') != 0){
$ascii = bcmod($code, '256');
$code = bcdiv($code, '256', 0);
$message .= chr($ascii);
}
}
return $message;
}
my code in b4a is
mine code in static mode:
Dim txt As String="71 71"
Dim d As BigInteger:d.Initialize(29)
Dim n As BigInteger:n.Initialize(91)
Dim e As BigInteger:e.Initialize(5)
Dim asci As BigInteger:asci.Initialize(256)
Dim spl() As String= Regex.Split(" ",txt)
txt=""
For i=0 To spl.Length-1
Dim temp As BigInteger:temp.Initialize(spl(i))
LogColor(temp.ToString,Colors.Green)
temp.Pow(d)
LogColor(temp.ToString,Colors.LightGray)
temp.Mod(n)
LogColor(temp.ToString,Colors.Red)
Do While temp.ToString<>"0"
Dim ascii As Int=temp.Mod(asci)
temp.Divide(asci)
LogColor(temp.ToString,Colors.Red)
txt=txt&Chr(ascii)
Loop
Next
LogColor(txt,Colors.Blue)
thanks...