Can You Solve This Big Integer Problem?
Update: I solved it … I just had to parse:
$val=[BigInt]::Parse("1111111111111111111")$val
On ASecuritySite, I have lots of examples of Python, Golang, Node.js, and JavaScript, so I have been converting a range of cryptography examples into PowerShell. The core advance of using PowerShell is that it can gain access to the .NET framework, and can run in a scripted way. It is also fairly fast in its operation and is fairly robust. If you want to see these examples, try here:
https://asecuritysite.com/powershell/
In cryptography, we often use integers which are much larger that the 64-bit ones supported by most compilers. Thus we turn to Big Integers, and which can be of any length. For example, we can perform the operation of $a to the power of $d, mod $n, with:
$x= [System.Numerics.BigInteger]::ModPow($a, $d, $n);
And, so I was working on a program to test for a prime number, and which uses the Miller-Rabin method. Everything works well, but I hit a problem when I parse a string value which represents an integer, and where I receive an incorrect value for the Big Integer value. The code is here: