Jump to content

Search the Community

Showing results for tags 'bignum'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • Announcements and Site News
    • Administration
  • AutoIt v3
    • AutoIt Help and Support
    • AutoIt Technical Discussion
    • AutoIt Example Scripts
  • Scripting and Development
    • Developer General Discussion
    • Language Specific Discussion
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Categories

  • AutoIt Team
    • Beta
    • MVP
  • AutoIt
    • Automation
    • Databases and web connections
    • Data compression
    • Encryption and hash
    • Games
    • GUI Additions
    • Hardware
    • Information gathering
    • Internet protocol suite
    • Maths
    • Media
    • PDF
    • Security
    • Social Media and other Website API
    • Windows
  • Scripting and Development
  • IT Administration
    • Operating System Deployment
    • Windows Client
    • Windows Server
    • Office

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Member Title


Location


WWW


Interests

Found 1 result

  1. My RSA script, 128 bit and lower fast (for UDF attachment) Using : "RSATool2v17.exe" open and input (E) key and Keysize (Bits) "128", Generate "P, Q, D". Copy "P, Q, D" to my code ; Script Start - Add your code below here #include <String.au3> #include "BigNum.au3" Global $P, $Q, $SelectBase = 64 $base64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ;base64 ;Sexagesimal $base60_2 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwx" ;sexagesimal $base32 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" ;base32 $base24 = "0123456789ABCDEFGHJKLMNP" ;base24 $base16 = "0123456789ABCDEF" ;hex ;Duodecimal system or dozenal $base12 = "0123456789AB" ;duodecimal $base10 = "0123456789" ;base10 $base8 = "01234567" ;oct $base2 = "01" ;binary $P = _BigNum_Add($P, "18429553113751821539") $Q = _BigNum_Add($Q, "14963134653035728619") $n = _BigNum_Mul($P, $Q) $PHI = _BigNum_Mul(_BigNum_Sub($P, 1), _BigNum_Sub($Q, 1)) $e = _NumToDec("10001100011000110001", $base16) $D = "263455903565562556840568120179103558669" ConsoleWrite(@CRLF) ConsoleWrite("P: " & NumberBase($P) & @CRLF) ConsoleWrite("Q: " & NumberBase($Q) & @CRLF) ConsoleWrite("N: " & NumberBase($n) & @CRLF) ConsoleWrite("PHI: " & NumberBase($PHI) & @CRLF & @CRLF) ConsoleWrite("D: " & NumberBase($D) & @CRLF) ConsoleWrite("E: " & NumberBase($e) & @CRLF & @CRLF) $Message = _NumToDec(_StringToHex("TEST MESSAGE"), $base16) If StringLen($Message) > StringLen($n) Then Exit (1) $c = _BigNum_PowerMod($Message, $e, $n) $D = _BigNum_PowerMod($c, $D, $n) ConsoleWrite("C: " & NumberBase($c) & @CRLF) ConsoleWrite("D: " & _HexToString(_DecToNum($D, $base16)) & @CRLF) ConsoleWrite(@CRLF) ;==================================================================================== ;~ Func modpow($a, $b, $c) ;~ $res = 1 ;~ While $b > 0 ;~ ;/* Need long multiplication else this will overflow... */ ;~ If Mod(StringRight($b, 1), 2) Then ;If BitAND($b,1) Then ;~ $res = _BigNum_Mod(_BigNum_Mul($res, $a), $c) ;~ EndIf ;~ $b = BitShift($b, 1) ;~ $a = _BigNum_Mod(_BigNum_Mul($a, $a), $c) ; /* Same deal here */ ;~ WEnd ;~ Return $res ;~ EndFunc ;==>modpow Func NumberBase($num, $base = $SelectBase) If $base = 10 Then Return _DecToNum($num, $base10) ElseIf $base = 16 Then Return _DecToNum($num, $base16) ElseIf $base = 60 Then Return _DecToNum($num, $base60_2) ElseIf $base = 64 Then Return _DecToNum($num, $base64) EndIf Return $num EndFunc ;==>NumberBase Func _DecToNum($iDec, $Symbol) Local $Out, $ost $Symbol = StringSplit($Symbol, '') If @error Or $Symbol[0] < 2 Then Return SetError(1, 0, $iDec) Do $ost = _BigNum_Mod($iDec, $Symbol[0]) $iDec = _BigNum_Div(_BigNum_Sub($iDec, $ost), $Symbol[0]) $Out = $Symbol[$ost + 1] & $Out Until Not Number($iDec) Return SetError(0, $Symbol[0], $Out) EndFunc ;==>_DecToNum Func _NumToDec($num, $sSymbol, $casesense = 1) Local $i, $iPos, $Len, $n, $Out $Len = StringLen($sSymbol) If $Len < 2 Then Return SetError(1, 0, $num) $n = StringSplit($num, '') For $i = 1 To $n[0] $iPos = StringInStr($sSymbol, $n[$i], $casesense) If Not $iPos Then Return SetError(2, 0, $num) $Out = _BigNum_Add(_BigNum_Mul($iPos - 1, _BigNum_Pow($Len, $n[0] - $i)), $Out) Next Return SetError(0, $Len, $Out) EndFunc ;==>_NumToDec ; #FUNCTION# ;==================================================================================== ; ; Name...........: _BigNum_PowerMod ; Description ...: Modular Exponentiation Mod($n^$e, $k) ; Syntax.........: _BigNum_Pow($n, $e, $k) ; Parameters ....: $n - Positive StringNumber: Digits"0"..."9" ; $e - Positive StringNumber: Exponent ; $k - Positive StringNumber: Modulus ; Return values .: Success - Result Mod($n^$e, $k) ; Failure - -1, sets @error to 1 if $n is not a positive valid StringNumber ; -1, sets @error to 2 if $e is not a positive valid StringNumber ; -1, sets @error to 3 if $k is not a positive valid StringNumber ; Author ........: jchd ; Date ..........: 17.12.13 ; Remarks .......: Fractional exponents not allowed - use BigNum_n_root instead. ; ;=============================================================================================== Func _BigNum_PowerMod($n, $e, $k) If Not __BigNum_IsValid_3($n, $e, $k) Then Return SetError(1, 0, -1) Local $res = "1" While $e <> "0" If Mod(StringRight($e, 1), 2) Then $res = _BigNum_Mod(_BigNum_Mul($res, $n), $k) $e = _BigNum_Sub($e, "1") EndIf $n = _BigNum_Mod(_BigNum_Mul($n, $n), $k) $e = _BigNum_Div($e, "2") WEnd Return $res EndFunc ;==>_BigNum_PowerMod Func __BigNum_IsValid_3($sX, $sY, $sZ) If StringRegExp($sX, "[^0-9.-]") Or StringRegExp($sY, "[^0-9.-]") Or StringRegExp($sZ, "[^0-9.-]") Then Return False Return True EndFunc ;==>__BigNum_IsValid_3 RSA 2 (TEST NOW).zip
×
×
  • Create New...