• ILOVALAR Dastur kodi
  • Zbekiston respublikasi raqamli texnologiyalar vazirligi muhammad al-xorazmiy




    Download 0,71 Mb.
    bet2/2
    Sana14.02.2024
    Hajmi0,71 Mb.
    #156117
    1   2
    Bog'liq
    Loyiha ishi

    M=Cd modN c-shifr matn, d-yopiq kalit, N- modul qiymati

    1.7-rasm
    Ochiq matn:
    30431515518975919430432425193963944787566618852518059630422
    65418276265111859623474514278370615776433121145111980289437
    50383158097308865582667234141682617128399593413643091833154
    02701609168849334368738491762847355545199988827316686875653 61407936079208046311512542263469562333298576618947456910330
    0961471019305145580519826740747511778114316716357
    ILOVALAR
    Dastur kodi
    import java.math.BigInteger; import java.util.ArrayList; import java.util.List;
    public class RSACrypt { public static BigInteger n = new
    BigInteger("3521965691682498349894156297871351510003392837134480208222044" + "4753957752560806765915557404471872854222134926440656261548716"
    +"5251895509139075621688493447805478090729096096693340629223579"
    + "5059531555148850225316762953811321830535065868925602454064437"
    + "6849173366230815779694365269990430445181132796913932904941185"
    + "478344783047790284034086549612594449881");
    public static void main(String[] args) {
    BigInteger c = new
    BigInteger("1946990934266279413917993964398835970466043305162067149027416"
    + "2053008128349816033069247844970800863920955661712219866590366"
    + "9590908102703307250646216395967327417349581565673419272952219" + "8445430968778476727718084419319887006224079130320273805411547" + "7138201099392091672934450078062438509784548210810385639731494"
    + "7527381565904894782921374911825451607");
    BigInteger e = new BigInteger("65537");
    List bigIntegers = pFactor();
    BigInteger p = bigIntegers.get(0);
    BigInteger q=bigIntegers.get(1);
    System.out.println("p = " + p);
    System.out.println("q = " + q);
    BigInteger f=p.subtract(BigInteger.ONE).multiply(q.subtract(BigInteger.ONE));
    BigInteger d = e.modInverse(f); System.out.println("d = " + d);
    BigInteger m = c.modPow(d, n);
    System.out.println("Ochiq matn: " + m);
    }
    public static List pFactor() {
    List result=new ArrayList<>();
    // P-algoritmini amalga oshirish
    BigInteger x = new BigInteger("2");
    BigInteger y = new BigInteger("2");
    BigInteger d = BigInteger.ONE; while (d.equals(BigInteger.ONE)) {
    x = f(x, n); y = f(f(y,n), n); d = gcd(x.subtract(y).abs(), n);
    }
    // Faktorlarni chiqarish if (d.equals(n)) { return null; } result.add(d); result.add(n.divide(d)); return result;
    }
    // Funksiyalarni aniqlash (x*x +1)%N public static BigInteger f(BigInteger x, BigInteger n) { return x.multiply(x).add(BigInteger.ONE).mod(n);
    }
    // 2 ta sonning ekubini topadi
    public static BigInteger gcd(BigInteger a, BigInteger
    b) { if (a.equals(BigInteger.ZERO)) {
    return b;
    }
    return gcd(b.mod(a), a);
    }
    }

    Download 0,71 Mb.
    1   2




    Download 0,71 Mb.

    Bosh sahifa
    Aloqalar

        Bosh sahifa



    Zbekiston respublikasi raqamli texnologiyalar vazirligi muhammad al-xorazmiy

    Download 0,71 Mb.